blob: 2b034da9336a140b87362293cc0ae5f7e79e80a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Re-snapping to the last snapped element on APZ</title>
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
body {
margin: 0;
}
div {
position: absolute;
}
#scroller {
width: 100%;
height: 500px;
overflow-y: scroll;
scroll-snap-type: y proximity; /* to escape from the last snap point */
}
.child {
width: 100%;
height: 100px;
background-color: blue;
scroll-snap-align: start;
}
</style>
</head>
<body>
<div id="scroller">
<div class="child" style="top: 0px;"></div>
<div class="child" style="top: 200px;"></div>
<div id="spacer" style="width: 100%; height: 2000px;"></div>
</div>
<script type="application/javascript">
async function test() {
const proximityThreshold =
SpecialPowers.getIntPref("layout.css.scroll-snap.proximity-threshold");
let transformEndPromise = promiseTransformEnd();
scroller.scrollBy({left: 0, top: 100, behavior: "smooth"});
await transformEndPromise;
await promiseApzFlushedRepaints();
is(scroller.scrollTop, 200, "snap to 200px");
document.querySelectorAll(".child")[1].style.top = "400px";
is(scroller.scrollTop, 400, "re-snap to 400px");
// Now trigger another async scroll to escape from the last snap point.
transformEndPromise = promiseTransformEnd();
scroller.scrollBy({left: 0, top: proximityThreshold + 100,
behavior: "smooth"});
// Expand the scrollable region during the async scroll.
spacer.style.height = "2200px";
await transformEndPromise;
await promiseApzFlushedRepaints();
isnot(scroller.scrollTop, 400, "Do not re-snap to the original 400px point");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</body>
</html>
|