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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> CSS Scroll Snap 2 Test: Snap Events with pseudo-element targets.</title>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-2/#snap-events">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/css/css-scroll-snap-2/resources/common.js"></script>
<script src="/css/css-scroll-snap-2/resources/user-scroll-common.js"></script>
<script src="/dom/events/scrolling/scroll_support.js"></script>
</head>
<body>
<style>
.scroller {
overflow: scroll;
width: 200px;
height: 200px;
border: solid 1px black;
scroll-snap-type: y mandatory;
position: absolute;
resize: both;
}
.space {
height: 300vh;
width: 300vw;
position: absolute;
}
.scroller::before, .scroller::after {
scroll-snap-align: start;
height: 50px;
width: 50px;
color: white;
display: block;
}
.scroller::before {
content: "before";
background-color: blue;
}
.scroller::after {
content: "after";
background-color: orange;
margin-top: 100px;
}
</style>
<div class="scroller" id="scroller">
<div class="space"></div>
</div>
<script>
const start_pos = {
x: scroller.clientWidth / 2,
y: scroller.clientHeight / 2,
};
const end_pos = { x: scroller.clientWidth / 2, y: 0 };
// The top of the ::after pseudo element is the sum of the
// ::before pseudo-element's height (50) and the ::after
// pseudo-element's margin-top (100).
const after_pseudo_element_top = 50 + 100;
const test_data = {
scroller: scroller,
scrolling_function: async () => {
await snap_event_touch_scroll_helper(start_pos, end_pos);
},
expected_snap_targets: { block: scroller, inline: null },
expected_scroll_offsets: {
x: 0,
y: after_pseudo_element_top,
}
};
promise_test(async (t) => {
await test_snapchanged(t, test_data);
}, "snapTarget for snapchanged is the owning element when a snap area " +
"belongs to a pseudo-element");
promise_test(async (t) => {
await test_snap_event(t, test_data, "snapchanging");
}, "snapTarget for snapchanging is the owning element when a snap area " +
"belongs to a pseudo-element");
</script>
</body>
</html>
|