File: scroll-snap-stop-002-nested.tentative.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (61 lines) | stat: -rw-r--r-- 1,767 bytes parent folder | download | duplicates (14)
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
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#scroll-snap-stop" />
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#snap-overflow" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
div {
  position: absolute;
}
.scroller {
  width: 400px;
  height: 100px;
  overflow: scroll;
  scroll-snap-type: x mandatory;
}
#space {
  left: 0px;
  top: 0px;
  width: 2100px;
  height: 50px;
}
.target {
  width: 50px;
  height: 50px;
  scroll-snap-align: start;
  top: 0px;
}
</style>

<div class="scroller" id="scroller7">
  <div id="space"></div>
  <div class="target" style="left:   0px;"></div>
  <div class="target" style="left: 400px; width: 900px;"></div>
  <div class="target" style="left: 900px; scroll-snap-stop: always;"></div
</div>

<script>

test(() => {
  assert_equals(scroller7.scrollLeft, 0);
  assert_equals(scroller7.scrollTop, 0);

  // start                                       dest  always
  //   |-------------------------|================|=====|=====
  //   0                        400              700   900

  // Scoll on the element whose snap area is larger than the snapport.
  scroller7.scrollBy(600, 0);
  // Stops before the smaller snap area @ 900px enters the snapport.
  assert_equals(scroller7.scrollLeft + scroller7.clientWidth, 900);
  assert_equals(scroller7.scrollTop, 0);

  scroller7.scrollTo(0, 0);
  scroller7.scrollBy(800, 0);
  // Now the smaller snap area is closer, so we snap to it.
  assert_equals(scroller7.scrollLeft, 900);
  assert_equals(scroller7.scrollTop, 0);
}, "`scroll-snap-stop: always` snap point is further than the scroll " +
   "destination and a snap area covers the snapport");

</script>