简体   繁体   中英

Media Queries with JavaScript

Hey Everyone I want to know that can I use Media Queries with JavaScript and how especially with 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

        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.

You can store the values of 'translateX' property of anime object in any variable. Then according to the screen size, you can set the values in that variable and ultimately assign the variable as the translateX property.

translateX: <your_variable>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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