@@ -30,6 +30,11 @@ urlPrefix: https://w3c.github.io/web-animations/; type: dfn; spec: web-animation
3030 text: start delay
3131 text: target effect end
3232 text: timeline
33+ text: phase; url: timeline-phase
34+ text: inactive phase; url: timeline-inactive-phase
35+ text: before phase; url: timeline-before-phase
36+ text: active phase; url: timeline-active-phase
37+ text: after phase; url: timeline-after-phase
3338urlPrefix: https://drafts.csswg.org/cssom-view/; type: dfn; spec: cssom-view-1
3439 text: CSS layout box
3540 text: overflow direction; url: overflow-directions
@@ -701,35 +706,86 @@ The procedure to calculate <dfn>effective scroll range</dfn> of a
701706
702707 </div>
703708
709+
710+ ### The phase of a {{ScrollTimeline}} ### {#phase-algorithm}
711+
712+ The [=phase=] of a {{ScrollTimeline}} is calculated as follows:
713+
714+ 1. If <em> any</em> of the following are true:
715+
716+ * {{source}} is null, or
717+ * {{source}} does not currently have a [=CSS layout box=] , or
718+ * {{source}} 's layout box is not a [=scroll container=] , or
719+ * [=effective scroll range=] is null.
720+
721+ The [=phase=] is [=inactive phase|inactive=] and abort remaining steps.
722+
723+ 1. Let <var> current scroll offset</var> be the current scroll offset of
724+ {{source}} in the direction specified by {{orientation}} .
725+
726+ 1. The [=phase=] is the result corresponding to the first matching condition
727+ from below:
728+
729+ <div class="switch">
730+
731+ : If <var> current scroll offset</var> is less than [=effective start offset=] :
732+ :: The [=phase=] is [=before phase|before=]
733+
734+ : If <var> current scroll offset</var> is greater than or equal to [=effective
735+ end offset=] <em> and</em> [=effective end offset=] is less than the maximum
736+ scroll offset of {{source}} in {{orientation}} :
737+
738+ :: The [=phase=] is [=after phase|after=]
739+
740+ Note: In web animations, in general ranges are normally exclusive of their end
741+ point. But there is an exception here for the scroll timeline active range as it
742+ may in some cases be inclusive of its end. In particular if the timeline end
743+ offset is the maximum scroll offset we include it in active range because it is
744+ not possible for user to scroll passed this point and not including this value
745+ in the active range would leave to animations that would not be active at the
746+ very last scroll position.
747+
748+ : Otherwise,
749+ :: The [=phase=] is [=active phase|active=] .
750+
751+ </div>
752+
704753### The current time of a {{ScrollTimeline}} ### {#current-time-algorithm}
705754
706755The [=current time=] of a {{ScrollTimeline}} is calculated as follows:
707756
708- 1. If {{source}} is null, does not currently have a [=CSS layout box=] , or if
709- its layout box is not a [=scroll container=] , return an unresolved time
710- value.
757+ 1. If <em> any</em> of the following are true:
711758
712- 1. Otherwise, let <var> current scroll offset</var> be the current scroll offset
713- of {{source}} in the direction specified by {{orientation}} .
759+ * {{source}} is null, or
760+ * {{source}} does not currently have a [=CSS layout box=] , or
761+ * {{source}} 's layout box is not a [=scroll container=] , or
762+ * [=effective scroll range=] is null.
714763
715- 1. If [=effective scroll range =] is null, return an unresolved time value.
764+ The [=current time =] is an unresolved time value and abort remaining steps .
716765
717- 1. If <var> current scroll offset</var> is less than [=effective start offset=] ,
718- return 0 .
766+ 1. Let <var> current scroll offset</var> be the current scroll offset of
767+ {{source}} in the direction specified by {{orientation}} .
719768
720- Issue(4325): Define what the correct timeline state is based on scroll
721- offset.
769+ 1. The [=current time=] is the result corresponding to the first matching
770+ condition from below:
722771
723- 1. If <var> current scroll offset</var> is greater than or equal to [=effective
724- end offset=] , return [=effective time range=] .
772+ <div class="switch">
773+
774+ : If <var> current scroll offset</var> is less than [=effective start offset=] :
775+ :: The [=current time=] is 0.
776+
777+ : If <var> current scroll offset</var> is greater than or equal to [=effective
778+ end offset=] :
779+ :: The [=current time=] is the [=effective time range=] .
725780
726- 1. Return the result of evaluating the following expression:
781+ : Otherwise,
782+ :: The [=current time=] is the result of evaluating the following expression:
727783
728784 <blockquote>
729785 <code> (<var> current scroll offset</var> - [=effective start offset=] ) / [=effective scroll range=] × [=effective time range=] </code>
730786 </blockquote>
731787
732-
788+ </div>
733789
734790Note: To be considered active a scroll timeline requires its [=effective start
735791offset=] and its [=effective end offset=] to be non-null. This means that for
0 commit comments