PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.0
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.0
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / hooks / use-responsive.js

use-responsive.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.7.0, at gutenberg/hooks/use-responsive.js

33 lines 769 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useDispatch, useSelect } from '@wordpress/data';
2
3 import { getMediaSizes } from '../utils/get-media-sizes';
4
5 export default function useResponsive() {
6 const { device } = useSelect((select) => {
7 const { getDevice } = select('ghostkit/responsive');
8
9 return {
10 device: getDevice(),
11 };
12 });
13
14 // Check if 'core/editor' store is available. It is not available in the Widgets editor.
15 const { setDeviceType } = useDispatch('core/editor') || {};
16 const { setDevice } = useDispatch('ghostkit/responsive');
17
18 const setDeviceWithReset = (...args) => {
19 setDevice(...args);
20
21 // Reset default preview device.
22 if (setDeviceType) {
23 setDeviceType('Desktop');
24 }
25 };
26
27 return {
28 device,
29 setDevice: setDeviceWithReset,
30 allDevices: getMediaSizes(),
31 };
32 }
33