@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 1.57 kB
Source Map (JSON)
{"version":3,"file":"view.cjs","names":["store","getContext","prefersReducedMotion","getElement"],"sources":["../../src/cover/view.js"],"sourcesContent":["import { getContext, getElement, store } from '@wordpress/interactivity';\nimport { prefersReducedMotion } from '../utils/reduced-motion';\n\nstore(\n\t'core/cover',\n\t{\n\t\tstate: {\n\t\t\tget videoSrc() {\n\t\t\t\tconst { src, reducedMotionSrc } = getContext();\n\n\t\t\t\t// The server renders the autoplaying source, so it is only\n\t\t\t\t// replaced for a visitor who has asked for reduced motion.\n\t\t\t\tif ( reducedMotionSrc && prefersReducedMotion() ) {\n\t\t\t\t\treturn reducedMotionSrc;\n\t\t\t\t}\n\n\t\t\t\treturn src;\n\t\t\t},\n\t\t},\n\t\tcallbacks: {\n\t\t\tstopBackgroundVideo() {\n\t\t\t\tif ( ! prefersReducedMotion() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The video is saved with `autoplay`, so it is stopped here\n\t\t\t\t// rather than never started. Clearing the attribute as well\n\t\t\t\t// keeps it from playing again if the source reloads.\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tref.autoplay = false;\n\t\t\t\tref.pause();\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],"mappings":";;;;;;;;CAGAA,GAAAA,yBAAAA,MAAAA,CACC,cACA;CACC,OAAO,EACN,IAAI,WAAW;EACd,MAAM,EAAE,KAAK,sBAAA,GAAqBC,yBAAAA,WAAAA,CAAW;EAI7C,IAAK,qBAAA,GAAoBC,2BAAAA,qBAAAA,CAAqB,GAC7C,OAAO;EAGR,OAAO;CACR,EACD;CACA,WAAW,EACV,sBAAsB;EACrB,IAAK,EAAA,GAAEA,2BAAAA,qBAAAA,CAAqB,GAC3B;EAMD,MAAM,EAAE,SAAA,GAAQC,yBAAAA,WAAAA,CAAW;EAC3B,IAAI,WAAW;EACf,IAAI,MAAM;CACX,EACD;AACD,GACA,EAAE,MAAM,KAAK,CACd"}