@@ -141,37 +141,27 @@ describe("timeline scroll targets", () => {
141141 } ) ;
142142} ) ;
143143
144- describe ( "createUpwardScrollDetector " , ( ) => {
145- it ( "reports a reader scrolling up, such as a scroll chained out of an embedded frame " , ( ) => {
146- const scrolledUp = createUpwardScrollDetector ( { top : 6621 , height : 7421 } ) ;
147- expect ( scrolledUp ( { top : 6471 , height : 7421 } ) ) . toBe ( true ) ;
148- expect ( scrolledUp ( { top : 6321 , height : 7421 } ) ) . toBe ( true ) ;
149- } ) ;
144+ describe ( "timeline scroll follow opt-out " , ( ) => {
145+ it ( "detects iframe-only upward scrolling after following streaming content " , ( ) => {
146+ const scrolledUp = createUpwardScrollDetector ( { top : 1000 , height : 1500 } ) ;
147+ expect ( scrolledUp ( { top : 1000 , height : 1800 } ) ) . toBe ( false ) ;
148+ expect ( scrolledUp ( { top : 1300 , height : 1800 } ) ) . toBe ( false ) ;
149+ expect ( scrolledUp ( { top : 1200 , height : 1700 } ) ) . toBe ( false ) ;
150150
151- it ( "ignores moves toward the end and content growing while it follows" , ( ) => {
152- const scrolledUp = createUpwardScrollDetector ( { top : 1000 , height : 2000 } ) ;
153- expect ( scrolledUp ( { top : 1000 , height : 2400 } ) ) . toBe ( false ) ;
154- expect ( scrolledUp ( { top : 1400 , height : 2400 } ) ) . toBe ( false ) ;
151+ // Sandboxed frames deliver no wheel or touch event to the parent timeline.
152+ expect ( scrolledUp ( { top : 1199.5 , height : 1700 } ) ) . toBe ( false ) ;
153+ expect ( scrolledUp ( { top : 1199 , height : 1700 } ) ) . toBe ( false ) ;
154+ expect ( scrolledUp ( { top : 1198.5 , height : 1700 } ) ) . toBe ( true ) ;
155155 } ) ;
156156
157- it ( "ignores the offset clamping up when content above the end shrinks " , ( ) => {
157+ it ( "preserves upward new-turn positioning, then detects the reader leaving that anchor " , ( ) => {
158158 const scrolledUp = createUpwardScrollDetector ( { top : 1400 , height : 2400 } ) ;
159- expect ( scrolledUp ( { top : 1100 , height : 2100 } ) ) . toBe ( false ) ;
160- // The next upward move is measured from the clamped position.
161- expect ( scrolledUp ( { top : 900 , height : 2100 } ) ) . toBe ( true ) ;
162- } ) ;
163-
164- it ( "ignores subpixel jitter" , ( ) => {
165- const scrolledUp = createUpwardScrollDetector ( { top : 500.5 , height : 2000 } ) ;
166- expect ( scrolledUp ( { top : 500 , height : 2000 } ) ) . toBe ( false ) ;
167- expect ( scrolledUp ( { top : 500.5 , height : 2000 } ) ) . toBe ( false ) ;
168- expect ( scrolledUp ( { top : 500 , height : 2000 } ) ) . toBe ( false ) ;
169- } ) ;
159+ // The caller must distinguish its animated positioning from iframe scroll chaining.
160+ const positioning = { top : 1200 , height : 2400 , programmatic : true } ;
161+ expect ( scrolledUp ( positioning ) ) . toBe ( false ) ;
162+ expect ( scrolledUp ( { ...positioning , top : 1100 } ) ) . toBe ( false ) ;
170163
171- it ( "adds up a slow scroll that moves under a pixel per event" , ( ) => {
172- const scrolledUp = createUpwardScrollDetector ( { top : 500 , height : 2000 } ) ;
173- expect ( scrolledUp ( { top : 499.5 , height : 2000 } ) ) . toBe ( false ) ;
174- expect ( scrolledUp ( { top : 499 , height : 2000 } ) ) . toBe ( false ) ;
175- expect ( scrolledUp ( { top : 498.5 , height : 2000 } ) ) . toBe ( true ) ;
164+ expect ( scrolledUp ( { top : 1100 , height : 2400 } ) ) . toBe ( false ) ;
165+ expect ( scrolledUp ( { top : 950 , height : 2400 } ) ) . toBe ( true ) ;
176166 } ) ;
177167} ) ;
0 commit comments