-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathscroll-state-scrolled-programmatic-relative-scrolls.html
More file actions
135 lines (122 loc) · 5.06 KB
/
Copy pathscroll-state-scrolled-programmatic-relative-scrolls.html
File metadata and controls
135 lines (122 loc) · 5.06 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<title>@container: scroll-state(scrolled) changed after scroll</title>
<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#scrolled">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/css-conditional/container-queries/support/cq-testcommon.js"></script>
<script src="/css/css-transitions/support/helper.js"></script>
<style>
#scroller {
width: 200px;
height: 200px;
container-type: scroll-state;
overflow-x: scroll;
overflow-y: scroll;
}
#filler {
height: 600px;
width: 600px;
}
#target {
--top: no;
--bottom: no;
--y: no;
--left: no;
--right: no;
--x: no;
--none: no;
@container scroll-state(scrolled: top) {
--top: yes;
}
@container scroll-state(scrolled: bottom) {
--bottom: yes;
}
@container scroll-state(scrolled: y) {
--y: yes;
}
@container scroll-state(scrolled: left) {
--left: yes;
}
@container scroll-state(scrolled: right) {
--right: yes;
}
@container scroll-state(scrolled: x) {
--x: yes;
}
@container scroll-state(scrolled: none) {
--none: yes;
}
}
</style>
<div id="scroller">
<div id="filler">
<div id="target"></div>
</div>
</div>
<script>
setup(() => assert_implements_scroll_state_container_queries());
promise_test(async t => {
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--none"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--y"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--left"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--right"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--x"), "no");
}, "Check that scroll-state(scrolled) state before scrolling");
promise_test(async t => {
scroller.scrollBy(0, -100);
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--none"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--y"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--left"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--right"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--x"), "no");
}, "Scrolling up when scrollbar is on the top should not change scroll-state(scrolled)");
promise_test(async t => {
scroller.scrollTop = 200;
scroller.scrollBy(0, -100, "instant");
scroller.scrollTop = 0;
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--none"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--y"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--x"), "no");
}, "Relative scroll followed by absolute scroll should change scroll scrolled");
promise_test(async t => {
scroller.scrollBy(0, 300);
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--y"), "yes");
assert_equals(scroller.scrollTop, 300);
}, "scroll-state(scrolled) after scrolling bottom");
promise_test(async t => {
scroller.scrollBy(0, -200);
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--y"), "yes");
assert_equals(scroller.scrollTop, 100);
}, "scroll-state(scrolled) after scrolling top");
promise_test(async t => {
scroller.scrollBy(300, 0);
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--left"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--right"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--x"), "yes");
assert_equals(scroller.scrollLeft, 300);
}, "scroll-state(scrolled) after scrolling right");
promise_test(async t => {
scroller.scrollBy(-200, 0);
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--left"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--right"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--x"), "yes");
assert_equals(scroller.scrollLeft, 100);
}, "scroll-state(scrolled) after scrolling left");
</script>