This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify/lib/mixins/translatable/index.js

56 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2019-08-11 18:48:02 +00:00
import Vue from 'vue';
export default Vue.extend({
name: 'translatable',
props: {
height: Number
},
data: () => ({
elOffsetTop: 0,
parallax: 0,
parallaxDist: 0,
percentScrolled: 0,
scrollTop: 0,
windowHeight: 0,
windowBottom: 0
}),
computed: {
imgHeight() {
return this.objHeight();
}
},
beforeDestroy() {
window.removeEventListener('scroll', this.translate, false);
window.removeEventListener('resize', this.translate, false);
},
methods: {
calcDimensions() {
const offset = this.$el.getBoundingClientRect();
this.scrollTop = window.pageYOffset;
this.parallaxDist = this.imgHeight - this.height;
this.elOffsetTop = offset.top + this.scrollTop;
this.windowHeight = window.innerHeight;
this.windowBottom = this.scrollTop + this.windowHeight;
},
listeners() {
window.addEventListener('scroll', this.translate, false);
window.addEventListener('resize', this.translate, false);
},
/** @abstract **/
objHeight() {
throw new Error('Not implemented !');
},
translate() {
this.calcDimensions();
this.percentScrolled = (this.windowBottom - this.elOffsetTop) / (parseInt(this.height) + this.windowHeight);
this.parallax = Math.round(this.parallaxDist * this.percentScrolled);
}
}
});
//# sourceMappingURL=index.js.map