简体   繁体   English

使用 JavaScript 进行媒体查询

[英]Media Queries with JavaScript

Hey Everyone I want to know that can I use Media Queries with JavaScript and how especially with Animejs.大家好,我想知道我可以在 JavaScript 中使用媒体查询吗,尤其是在 Animejs 中如何使用。

    var morphing = anime({
        targets: '.polymorph',
        points: [{
            value: '405,219 0,219 0,0 70,0 77.5,0 84,0 151.5,154.5'
        }, ],
        easing: 'easeOutQuad',
        duration: 1500,
        loop: false
    });

    anime({
        targets: '#blip',
        opacity: 1,
        duration: 7000,
        translateX: 290,
        loop: true
    })

I want to change duration and translateX when it is viewed in mobile device我想在移动设备中查看时更改持续时间和 translateX

        anime ({
        targets: '#blip',
        opacity: 1,
        duration: 7000,
        translateX: 290,
        loop: true
     })

Thanks谢谢

You can check the screen size of the window using screen.width() in your javascript code.您可以使用 javascript 代码中的screen.width()检查窗口的屏幕大小。

You can store the values of 'translateX' property of anime object in any variable.您可以将动漫对象的“translateX”属性值存储在任何变量中。 Then according to the screen size, you can set the values in that variable and ultimately assign the variable as the translateX property.然后根据屏幕大小,您可以在该变量中设置值,并最终将该变量指定为 translateX 属性。

translateX: <your_variable>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM