-
-
Save alejandroiglesias/c4721d23aa5f777fcaf80a1d4cf5c0f4 to your computer and use it in GitHub Desktop.
Reactive Window Parameters in Vue.js - Adapted from: https://blog.usejournal.com/reactive-window-parameters-in-vuejs-fc5de75d7ab5
This file contains 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
import Vue from 'vue' | |
export default class extends Vue { | |
constructor() { | |
super({ | |
data() { | |
return { | |
scrollY: 0 | |
} | |
}, | |
created() { | |
window.addEventListener('scroll', e => { | |
this.scrollY = window.scrollY | |
}) | |
}, | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version of
WindowInstanceMap.js
from James Wee requires you to instantiate the class so that you don't have seemingly unused imports:This would make it a much preferred solution since seemingly unused imports can be removed either by automatic processes or human beings unaware of the details of the import.