File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
css/css-scroll-snap/snap-after-relayout Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < link rel ="help " href ="https://drafts.csswg.org/css-scroll-snap/#re-snap " />
3+ < link rel ="help " href ="https://bugzilla.mozilla.org/show_bug.cgi?id=1948861 ">
4+ < script src ="/resources/testharness.js "> </ script >
5+ < script src ="/resources/testharnessreport.js "> </ script >
6+ < style >
7+ # scroller {
8+ scroll-snap-type : y mandatory;
9+ width : 500px ;
10+ height : 200px ;
11+ overflow-y : scroll;
12+ overflow-x : hidden;
13+ scrollbar-width : none;
14+ }
15+ .child {
16+ scroll-snap-align : start;
17+ width : 500px ;
18+ height : 100% ;
19+ }
20+ video {
21+ height : 100% ;
22+ }
23+ </ style >
24+ < div id ="container ">
25+ < div id ="scroller ">
26+ < div class ="child ">
27+ < video src ="dummy.webm " controls autoplay >
28+ </ div >
29+ < div class ="child ">
30+ < video src ="dummy.webm " controls autoplay >
31+ </ div >
32+ < div class ="child ">
33+ < video src ="dummy.webm " controls autoplay >
34+ </ div >
35+ </ div >
36+ </ div >
37+ < script >
38+ promise_test ( async ( ) => {
39+ assert_equals ( scroller . scrollTop , 0 ) ;
40+
41+ const scrollendPromise = new Promise ( resolve => {
42+ scroller . addEventListener ( "scrollend" , resolve ) ;
43+ } ) ;
44+ // Try to scroll downward, it will snap to the second green box.
45+ scroller . scrollBy ( { top : 100 , behavior : "smooth" } ) ;
46+ await scrollendPromise ;
47+
48+ // Change the parent position style so that the scroll container will
49+ // be reconstructed.
50+ container . style . position = "fixed" ;
51+
52+ assert_equals ( scroller . scrollTop , 200 , "Should stay at the last snap point" ) ;
53+ } , "Stay at the last snap point even after reconstrucing the scroll container" ) ;
54+ </ script >
You can’t perform that action at this time.
0 commit comments