File: scroll-marker-active-unreached-target.html

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (113 lines) | stat: -rw-r--r-- 3,371 bytes parent folder | download | duplicates (9)
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
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>CSS Test: test that the scroll-marker of a target whose target position
    has not been reached only gets selected when it is within half a scroll
    port's distance from the current scroll offset</title>
  <link rel="help" href="https://drafts.csswg.org/css-overflow-5/#example-d2ca6884">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/resources/testdriver.js"></script>
  <script src="/resources/testdriver-vendor.js"></script>
  <script src="support/scroll-marker-support.js"></script>
  <script src="/dom/events/scrolling/scroll_support.js"></script>
</head>

<body>
  <style>
  .wrapper {
    display: grid;
    justify-content: center;
    position: relative;
  }

  .carousel {
    width: 600px;
    height: 512px;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    list-style-type: none;
    scroll-behavior: smooth;
    border: solid 2px grey;
    padding-left: 0px;
    white-space: nowrap;
    position: relative;

    &>.item {
      height: 80%;
      width: 120px;
      border: 1px solid;
      place-content: center;
      background-color: white;
      margin-right: 1200px;
      display: inline-block;

      &::scroll-marker {
        content: ' ';
        width: 35px;
        height: 35px;
        border: 3px solid gray;
        border-radius: 50%;
        margin: 3px;
        background-color:red;
      }

      &::scroll-marker:target-current {
        background-color: green;
      }
    }

    scroll-marker-group: after;
    &::scroll-marker-group {
      height: 45px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: solid 1px black;
      border-radius: 30px;
    }
  }

  </style>
  <div id="wrapper" class="wrapper">
    <div class="carousel" id="carousel">
      <div class="item" id="item1" tabindex=0>1</div>
      <div class="item" id="item2" tabindex=0>2</div>
    </div>
  </div>
  <script>
    RED = "rgb(255, 0, 0)";
    GREEN = "rgb(0, 128, 0)";

    promise_test(async (t) => {
      await waitForCompositorCommit();
      const items = carousel.querySelectorAll(".item");

      assert_equals(carousel.scrollLeft, 0,  "carousel is not scrolled");
      verifySelectedMarker(0, items, GREEN, RED);

      // Scroll a bit, but not enough to bring item2 into view. Item1 should
      // still be selected.
      let pos = item2.offsetLeft - carousel.clientWidth - 10;
      await waitForScrollReset(t, carousel, pos);
      verifySelectedMarker(0, items, GREEN, RED);

      // Scroll a bit more; bring item2 into view but only into the second half
      // of the scroll port. Item1 should still be selected.
      pos = item2.offsetLeft - carousel.clientWidth + item2.offsetWidth;
      await waitForScrollReset(t, carousel, pos);
      verifySelectedMarker(0, items, GREEN, RED);

      // Scroll to place item2 within the half a scroll port's width from the
      // current scroll offset. Item2 should now be selected.
      pos += carousel.clientWidth / 2;
      await waitForScrollReset(t, carousel, pos);
      verifySelectedMarker(1, items, GREEN, RED);
    }, "target whose target position is not yet reached only get selected " +
       "when its less than half a scroll port away.");
  </script>
</body>

</html>