-
-
Save lmiller1990/b77b7322560bf6f9835fb627c03d71af to your computer and use it in GitHub Desktop.
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' | |
import { getScrollPercentage } from './progress' | |
interface IData { | |
percent: number | |
scrollEvent: ((this: Window, ev: Event) => void) | null | |
} | |
export default Vue.extend({ | |
name: 'Progress', | |
data(): IData { | |
return { | |
percent: 0, | |
scrollEvent: null, | |
} | |
}, | |
mounted() { | |
const progressStartMarker = document.querySelector<HTMLElement>('#progress-marker-start') | |
const progressEndMarker = document.querySelector<HTMLElement>('#progress-marker-end') | |
if (!progressStartMarker || !progressEndMarker) { | |
throw Error('Progress markers not found') | |
} | |
window.addEventListener('scroll', () => { | |
this.percent = getScrollPercentage(progressStartMarker, progressEndMarker) | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment