@wordpress/block-library
Version:
Block library for the WordPress editor.
24 lines (21 loc) • 544 B
JavaScript
import { getElement, store } from '@wordpress/interactivity';
import { prefersReducedMotion } from '../utils/reduced-motion';
store(
'core/video',
{
callbacks: {
stopAutoplay() {
if ( ! prefersReducedMotion() ) {
return;
}
// The video is saved with `autoplay`, so it is stopped here
// rather than never started. Clearing the attribute as well
// keeps it from playing again if the source reloads.
const { ref } = getElement();
ref.autoplay = false;
ref.pause();
},
},
},
{ lock: true }
);