mediaQueries
Defines the media queries to match for conditionally refreshing the Scope when one of their matches state changes.
Media queries matching states are accessible via the scope matches property.
Accepts
An Object where
keyis an arbitrary nameStringfor the media query.Valueis the media query definitionString.
mediaQueries code example
import { createScope, animate } from 'animejs';
createScope({
mediaQueries: {
isSmall: '(max-width: 100px)',
isMedium: '(min-width: 101px) and (max-width: 200px)',
isLarge: '(min-width: 201px)',
reduceMotion: '(prefers-reduced-motion)',
}
})
.add(self => {
const { isSmall, isMedium, isLarge, reduceMotion } = self.matches;
utils.set('.square', { scale: isMedium ? .75 : isLarge ? 1 : .5 });
animate('.square', {
x: isSmall ? 0 : ['-35vw', '35vw'],
y: isSmall ? ['-40vh', '40vh'] : 0,
rotate: 360,
loop: true,
alternate: true,
duration: reduceMotion ? 0 : isSmall ? 750 : 1250
});
});
<div class="iframe-content resizable">
<div class="large centered row">
<div class="col">
<div class="square"></div>
</div>
</div>
</div>