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/es5/mixins/translatable/index.js
2019-08-11 20:48:02 +02:00

64 lines
No EOL
1.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _vue = _interopRequireDefault(require("vue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = _vue.default.extend({
name: 'translatable',
props: {
height: Number
},
data: function data() {
return {
elOffsetTop: 0,
parallax: 0,
parallaxDist: 0,
percentScrolled: 0,
scrollTop: 0,
windowHeight: 0,
windowBottom: 0
};
},
computed: {
imgHeight: function imgHeight() {
return this.objHeight();
}
},
beforeDestroy: function beforeDestroy() {
window.removeEventListener('scroll', this.translate, false);
window.removeEventListener('resize', this.translate, false);
},
methods: {
calcDimensions: function calcDimensions() {
var 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: function listeners() {
window.addEventListener('scroll', this.translate, false);
window.addEventListener('resize', this.translate, false);
},
/** @abstract **/
objHeight: function objHeight() {
throw new Error('Not implemented !');
},
translate: function translate() {
this.calcDimensions();
this.percentScrolled = (this.windowBottom - this.elOffsetTop) / (parseInt(this.height) + this.windowHeight);
this.parallax = Math.round(this.parallaxDist * this.percentScrolled);
}
}
});
exports.default = _default;
//# sourceMappingURL=index.js.map