-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathscroll-state-scrolled-programmatic-absolute-scrolls.html
More file actions
104 lines (94 loc) · 3.59 KB
/
scroll-state-scrolled-programmatic-absolute-scrolls.html
File metadata and controls
104 lines (94 loc) · 3.59 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
<!DOCTYPE html>
<title>@container: scroll-state(scrolled) ignores absolute scrolls</title>
<link rel="help" href="https://un5n798jx6qx6j0rmf2verhh.julianrbryant.com/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.scrollTop = 300;
scroller.scrollLeft = 300;
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");
assert_equals(scroller.scrollTop, 300);
assert_equals(scroller.scrollLeft, 300);
}, "scrollTop and scrollLeft scrolls should not affect scroll-state(scrolled)");
promise_test(async t => {
scroller.scrollTo(0, 100);
scroller.scrollTo(100, 0);
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");
}, "scrollTo scrolls should not affect scroll-state(scrolled)");
</script>