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
|
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#unreachable" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.scroller {
width: 100vw;
height: 100px;
display: flex;
scroll-snap-type: x mandatory;
overflow-x: auto;
}
.scroller.rtl {
direction: rtl;
}
.scroller.end > span {
scroll-snap-align: end;
}
.scroller.center > span {
scroll-snap-align: end;
}
</style>
<div class="scroller end">
<span style="min-width: 25px;"></span>
<span style="min-width: 100vw;"></span>
</div>
<div class="scroller center">
<span style="min-width: 25px;"></span>
<span style="min-width: 100vw;"></span>
</div>
<div class="scroller end rtl">
<span style="min-width: 25px;"></span>
<span style="min-width: 100vw;"></span>
</div>
<div class="scroller center rtl">
<span style="min-width: 25px;"></span>
<span style="min-width: 100vw;"></span>
</div>
<script>
test(() => {
const scroller = document.querySelector(".scroller.end");
assert_equals(scroller.scrollLeft, 0);
assert_equals(scroller.scrollTop, 0);
}, "Unreachable snap point with `scroll-snap-align: end`");
test(() => {
const scroller = document.querySelector(".scroller.center");
assert_equals(scroller.scrollLeft, 0);
assert_equals(scroller.scrollTop, 0);
}, "Unreachable snap point with `scroll-snap-align: center`");
test(() => {
const scroller = document.querySelector(".scroller.end.rtl");
assert_equals(scroller.scrollLeft, 0);
assert_equals(scroller.scrollTop, 0);
}, "Unreachable snap point with `scroll-snap-align: end` in RTL");
test(() => {
const scroller = document.querySelector(".scroller.center.rtl");
assert_equals(scroller.scrollLeft, 0);
assert_equals(scroller.scrollTop, 0);
}, "Unreachable snap point with `scroll-snap-align: center` in RTL");
</script>
</html>
|