Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. SnapEvent
  4. snapTargetBlock

SnapEvent: snapTargetBlock property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

ThesnapTargetBlock read-only property of theSnapEvent interface returns a reference to the element snapped to in the block direction when the event fired.

Specifically:

  • In the case of thescrollsnapchanging event, this refers to a pending block-direction snap target (i.e., it will be selected when the current scroll gesture ends).
  • In the case of thescrollsnapchange event, this refers to a newly-selected block-direction snap target.

The property values available onSnapEvent correspond directly to the value of thescroll-snap-type CSS property set on the scroll container.snapTargetBlock only returns an element reference if the snap axis is specified asblock (or a physical axis value that equates toblock in the current writing mode) orboth.

Value

ANode representing the snapped element, ornull if scroll snapping only occurs in the inline direction so no element is snapped to in the block direction.

If the snapped element was a pseudo-element, the returnedNode will be the owning element of that pseudo-element.

Examples

See the mainSnapEvent page for brief examples, and ourUsing scroll snap events guide for full examples and explanation.

Specifications

Specification
CSS Scroll Snap Module Level 2
# dom-snapevent-snaptargetblock

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp