File: targeted-scroll-marker-selection-with-transition.tentative.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1~deb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie-proposed-updates
  • size: 4,609,412 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 (137 lines) | stat: -rw-r--r-- 4,558 bytes parent folder | download | duplicates (10)
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
136
137
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>CSS Test: selection of scroll-markers for targeted scrolls (with transitions mid-scroll)</title>
  <link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-marker-pseudo">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/dom/events/scrolling/scroll_support.js"></script>
  <script src="support/scroll-marker-support.js"></script>
</head>

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

    .carousel {
      display: grid;
      grid-auto-flow: column;
      width: 1600px;
      height: 512px;
      overflow-x: scroll;
      scroll-snap-type: x mandatory;
      list-style-type: none;
      scroll-behavior: smooth;
      border: solid 2px grey;
      padding-top: 10%;
      text-align: center;
      counter-set: markeridx -1;

        &>.item {
          scroll-snap-align: center;
          height: 80%;
          width: 318px;
          border: 1px solid;
          place-content: center;

          &::scroll-marker {
            content: counter(markeridx);
            counter-increment: markeridx;
            align-content: center;
            text-align: center;
            width: 35px;
            height: 35px;
            border: 3px solid gray;
            border-radius: 50%;
            margin: 3px;
            background-color: red;
          }

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

      .item.active>p {
        font-size: 2em;
      }
      .item>p {
        transition: font-size 1s ;
      }

      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 class="wrapper" id="wrapper">
    <div class="carousel" id="carousel">
      <div class="item" id="item0" tabindex=0><p>0</p></div>
      <div class="item" id="item1" tabindex=0><p>1</p></div>
      <div class="item" id="item2" tabindex=0><p>2</p></div>
      <div class="item" id="item3" tabindex=0><p>3</p></div>
      <div class="item" id="item4" tabindex=0><p>4</p></div>
      <div class="item" id="item5" tabindex=0><p>5</p></div>
      <div class="item" id="item6" tabindex=0><p>6</p></div>
      <div class="item" id="item7" tabindex=0><p>7</p></div>
      <div class="item" id="item8" tabindex=0><p>8</p></div>
      <div class="item" id="item9" tabindex=0><p>9</p></div>
      <div class="item" id="item10" tabindex=0><p>10</p></div>
      <div class="item" id="item11" tabindex=0><p>11</p></div>
      <div class="item" id="item12" tabindex=0><p>12</p></div>
      <div class="item" id="item13" tabindex=0><p>13</p></div>
      <div class="item" id="item14" tabindex=0><p>14</p></div>
      <div class="item" id="item15" tabindex=0><p>15</p></div>
    </div>
  </div>
  <script>

    const carousel = document.getElementById("carousel");
    const items = document.querySelectorAll(".item");
    const wrapper = document.getElementById("wrapper");

    RED = "rgb(255, 0, 0)";
    GREEN = "rgb(0, 128, 0)";

    const max_scroll_offset = carousel.scrollWidth - carousel.clientWidth;
    async function testTargetedHasActiveMarker(test, element, expected_idx) {
      // Start from somewhere in the middle, ensuring that scrolling to the
      // extremes generates scrollend events.
      await waitForScrollReset(test, carousel, max_scroll_offset / 2);
      const color =
        getComputedStyle(items[expected_idx], "::scroll-marker").backgroundColor;
      assert_not_equals(color, GREEN,
        `Target item ${expected_idx} is not selected yet.`);
      const scrollend_promise = waitForScrollendEventNoTimeout(carousel);
      element.classList.add("active");
      element.scrollIntoView({behavior: "smooth"});
      await scrollend_promise;
      verifySelectedMarker(expected_idx, items, GREEN, RED);
      element.classList.remove("active");
    }

    promise_test(async(t) => {
      const target_item = items[1];
      await testTargetedHasActiveMarker(t, target_item, 1);
    }, "scroll-marker of target (idx 1) of scrollIntoView is selected");

    promise_test(async(t) => {
      const target_item = items[14];
      await testTargetedHasActiveMarker(t, target_item, 14);
    }, "scroll-marker of target (idx 14) of scrollIntoView is selected");
  </script>
</body>

</html>