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/scrollable/index.js

109 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _directives = require("../../directives");
var _console = require("../../util/console");
var _vue = _interopRequireDefault(require("vue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Directives
// Utilities
// Types
/**
* Scrollable
*
* Used for monitoring scrolling and
* invoking functions based upon
* scrolling thresholds being
* met.
*/
/* @vue/component */
var _default = _vue.default.extend({
name: 'scrollable',
directives: {
Scroll: _directives.Scroll
},
props: {
scrollTarget: String,
scrollThreshold: [String, Number]
},
data: function data() {
return {
currentScroll: 0,
currentThreshold: 0,
isActive: false,
isScrollingUp: false,
previousScroll: 0,
savedScroll: 0,
target: null
};
},
computed: {
/**
* A computed property that returns
* whether scrolling features are
* enabled or disabled
*/
canScroll: function canScroll() {
return typeof window !== 'undefined';
},
/**
* The threshold that must be met before
* thresholdMet function is invoked
*/
computedScrollThreshold: function computedScrollThreshold() {
return this.scrollThreshold ? Number(this.scrollThreshold) : 300;
}
},
watch: {
isScrollingUp: function isScrollingUp() {
this.savedScroll = this.savedScroll || this.currentScroll;
},
isActive: function isActive() {
this.savedScroll = 0;
}
},
mounted: function mounted() {
if (this.scrollTarget) {
this.target = document.querySelector(this.scrollTarget);
if (!this.target) {
(0, _console.consoleWarn)("Unable to locate element with identifier ".concat(this.scrollTarget), this);
}
}
},
methods: {
onScroll: function onScroll() {
var _this = this;
if (!this.canScroll) return;
this.previousScroll = this.currentScroll;
this.currentScroll = this.target ? this.target.scrollTop : window.pageYOffset;
this.isScrollingUp = this.currentScroll < this.previousScroll;
this.currentThreshold = Math.abs(this.currentScroll - this.computedScrollThreshold);
this.$nextTick(function () {
if (Math.abs(_this.currentScroll - _this.savedScroll) > _this.computedScrollThreshold) _this.thresholdMet();
});
},
/**
* The method invoked when
* scrolling in any direction
* has exceeded the threshold
*/
thresholdMet: function thresholdMet() {}
}
});
exports.default = _default;
//# sourceMappingURL=index.js.map