[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/blocks/ -> image.js (summary)

WordPress dependencies

File Size: 521 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 functions

  handleScroll()
  setStyles()
  debounce()

Functions
Functions that are not part of a class:

handleScroll(ctx)   X-Ref
Lightbox page-scroll handler: prevents scrolling.

This handler is added to prevent scrolling behaviors that
trigger content shift while the lightbox is open.

It would be better to accomplish this through CSS alone, but
using overflow: hidden is currently the only way to do so, and
that causes the layout to shift and prevents the zoom animation
from working in some cases because we're unable to account for
the layout shift when doing the animation calculations. Instead,
here we use JavaScript to prevent and reset the scrolling
behavior. In the future, we may be able to use CSS or overflow: hidden
instead to not rely on JavaScript, but this seems to be the best approach
for now that provides the best visual experience.

param: {Object} ctx Context object with the `core/image` namespace.

setStyles(ctx, ref)   X-Ref
Computes styles for the lightbox and adds them to the document.

param: {Object} ctx - Context for the `core/image` namespace.
param: {Object} ref - The element reference.

debounce(func, wait = 50)   X-Ref
Debounces a function call.

param: {Function} func - A function to be called
param: {number}   wait - The time to wait before calling the function



Generated : Wed Jan 31 08:20:02 2024 Cross-referenced by PHPXref