Last active
February 8, 2022 12:22
-
-
Save cp-sumi-k/cd60eb35f8bc0d742bb8d20d6e14ba68 to your computer and use it in GitHub Desktop.
https://blog.canopas.com/animations-with-css-and-vue-transitions-fdb53dbb21e7 - continous-horizontal-animation-6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
data() { | |
return { | |
grid1: [...], | |
grid2: [...], | |
lastScrollY: 0, | |
gridAnimation: "", | |
}; | |
}, | |
methods: { | |
scrollHandler() { | |
let diff = window.scrollY - this.lastScrollY; | |
//scroll up | |
if (diff < 0) { | |
this.gridAnimation = "grid-animation-reverse-running"; | |
} else { | |
this.gridAnimation = ""; | |
} | |
this.lastScrollY = window.scrollY; | |
}, | |
}, | |
mounted() { | |
window.addEventListener("scroll", this.scrollHandler); | |
}, | |
unmounted() { | |
window.removeEventListener("scroll", this.scrollHandler); | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment