Closed giticon closed 3 years ago
Hi, I just tested ScrollTrigger.matchMedia
and it works as expected.
Here are simple example from the official docs:
index.vue
<template>
<div style="min-height: 200vh">
<p class="panel">Example</p>
</div>
</template>
<script>
export default {
mounted() {
this.$ScrollTrigger.matchMedia({
// desktop
'(min-width: 800px)': () => {
// setup animations and ScrollTriggers for screens 800px wide or greater (desktop) here...
// These ScrollTriggers will be reverted/killed when the media query doesn't match anymore.
this.$gsap.to('.panel', {
xPercent: 100,
scrollTrigger: {
trigger: '.panel',
scrub: 1,
pin: true,
end: '+=500',
},
})
},
})
},
}
</script>
Test env:
create-nuxt-app
v2.15.4
v1.3.1
Thank you Ivo!. The problem was here
error:
'(min-width: 800px)': function() {
the solution is arrow function
'(min-width: 800px)': () => {
Np 👍 I'm glad it worked for you
There's a problem with matchMedia()
Error
Correct