Skip to content

[css-scroll-snap-2] Add SnapEvent definition #9515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 19, 2024
Merged

Conversation

DavMila
Copy link
Contributor

@DavMila DavMila commented Oct 23, 2023

SnapEvent defines the interface of scroll-snap-related JavaScript events, snapchanged and snapchanging.

@DavMila
Copy link
Contributor Author

DavMila commented Oct 23, 2023

Hi, @flackr , ptal at this addition of SnapEvent definition to the scroll-snap-2 spec.

PS: I don't seem to be able to add reviewers so I thought I'd just ping you.

@DavMila DavMila requested a review from flackr January 15, 2024 17:05
SnapEvent defines the interface of scroll-snap-related JavaScript
events, snapchanged and snapchanging.
Snap events should fire during scrolling. This is to specify when the
events should fire with respect to other scrolling events.
@tabatkins
Copy link
Member

@emilio (or @smfr) could you review the additions to the CSSOM View spec here? We want to make sure we're not monkey-patching awkwardly.

@DavMila DavMila requested a review from flackr February 8, 2024 14:45
@emilio
Copy link
Collaborator

emilio commented Feb 22, 2024

@emilio (or @smfr) could you review the additions to the CSSOM View spec here? We want to make sure we're not monkey-patching awkwardly.

It seems fine with stuff fixed (I just noticed that @flackr had caught some of the issues I pointed out too, whoops).

-Remove extra spaces.
-Improve snapchanging description.
-Append snap containers to event targets list only once.
-Explicitly reflect patch to cssom-view.
@DavMila DavMila requested review from flackr and emilio February 22, 2024 19:35
- Streamline snap events algorithms to one location, and link to them
  from cssom-view spec.
- Specify SnapEventInit
- Indicate event target in scroll steps.
- Let snap events fire upon the first snap.
- Specify snap events when re-snapping due on layout changes.
@DavMila DavMila requested a review from flackr March 7, 2024 14:43
- Make steps clearer by separating block and  inline if conditions for
  "update snapchanged targets" and layout change algorithm.
- Don't fire snap events synchronously.
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369681
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273041}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369681
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273041}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch updates chromium snapchanging code so that snapchanging
events use the updated SnapEvents API[1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I844fbbf9b43c1b5759ada0d341ce1532661d39a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369682
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273042}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 14, 2024
This patch updates chromium snapchanging code so that snapchanging
events use the updated SnapEvents API[1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I844fbbf9b43c1b5759ada0d341ce1532661d39a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369682
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273042}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 15, 2024
…ent interface as deprecated., a=testonly

Automatic update from web-platform-tests
[css-scroll-snap-2] Mark obsolete SnapEvent interface as deprecated.

The new interface is described in [1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I1985757eed10d15433590e35438b83e4db09a092
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369679
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1272921}

--

wpt-commits: c9a1cb97473bb77fe4259d81a739f64e7f8ad167
wpt-pr: 45089
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Mar 17, 2024
…ent interface as deprecated., a=testonly

Automatic update from web-platform-tests
[css-scroll-snap-2] Mark obsolete SnapEvent interface as deprecated.

The new interface is described in [1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I1985757eed10d15433590e35438b83e4db09a092
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369679
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1272921}

--

wpt-commits: c9a1cb97473bb77fe4259d81a739f64e7f8ad167
wpt-pr: 45089
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 19, 2024
…o updated SnapEvent interface, a=testonly

Automatic update from web-platform-tests
[css-scroll-snap-2] Switch snapchanged to updated SnapEvent interface

This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369681
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273041}

--

wpt-commits: 2817af77c7e8465130e93b5d4935e0887dd8ea81
wpt-pr: 45109
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 19, 2024
…to updated SnapEvents interface, a=testonly

Automatic update from web-platform-tests
[css-scroll-snap-2] Switch snapchanging to updated SnapEvents interface

This patch updates chromium snapchanging code so that snapchanging
events use the updated SnapEvents API[1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I844fbbf9b43c1b5759ada0d341ce1532661d39a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369682
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273042}

--

wpt-commits: 49339277bcf945dd569ace5cf3c7be961f93071b
wpt-pr: 45114
@tabatkins tabatkins merged commit ea83970 into w3c:main Mar 19, 2024
BruceDai pushed a commit to BruceDai/wpt that referenced this pull request Mar 25, 2024
The new interface is described in [1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I1985757eed10d15433590e35438b83e4db09a092
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369679
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1272921}
BruceDai pushed a commit to BruceDai/wpt that referenced this pull request Mar 25, 2024
This patch makes snapchanged fire SnapEvents based on the updated[1]
SnapEvent interface which supplies exactly one snap target per axis.

We detect that the snap targets of a SnapContainerData has changed by
comparing its current target_snap_area_element_ids_ to the element ids
that were most recently used to evaluate snapchanged. This requires
that if a snap container is snapped in both axes but is then scrolled
in only one axis, it needs to remember what it was snapped to in the
other (unscrolled) axis - previously, we simply forgot what we were
snapped to in the unscrolled axis.

prefer-common-to-both-axes.html had to be modified because remembering
what we are snapped to in the unscrolled axis affects the choice of
snap targets when there is a layout change resulting in the targets
along each axis not being mutually visible. Currently, chromium handles
this somewhat arbitrarily (This will be adddressed in
crbug.com/329250094) This patch gets around this by scrolling in both
axes.

snapchanged-ensures-dom-order.html is deleted because we don't return a
list anymore so we don't need to ensure the order of the list.

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I4af884bd58d0517087a8c8960bf7646f3a36ba72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369681
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273041}
BruceDai pushed a commit to BruceDai/wpt that referenced this pull request Mar 25, 2024
This patch updates chromium snapchanging code so that snapchanging
events use the updated SnapEvents API[1].

[1]w3c/csswg-drafts#9515

Bug: 329111147
Change-Id: I844fbbf9b43c1b5759ada0d341ce1532661d39a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5369682
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273042}
@DavMila DavMila deleted the snap-event-def branch March 25, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants