zcloud-ui
Version:
A Component Library for Vue.js.
35 lines (31 loc) • 1.05 kB
JavaScript
;
exports.__esModule = true;
var _lodash = require('lodash');
var autoHeigth = function autoHeigth(el, binding, vnode) {
var clientTop = el && el.getBoundingClientRect().top;
var limitH = Number(binding.value) || 0;
var elHeight = window.innerHeight - clientTop - limitH - 30;
el.style.height = elHeight + 'px';
};
var debounceFunc = (0, _lodash.debounce)(autoHeigth, 500);
var listener = function listener() {
debounceFunc.apply(undefined, arguments);
};
exports.default = {
bind: function bind() {
for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
autoHeigth.apply(undefined, rest);
window.addEventListener('resize', listener.bind.apply(listener, [this].concat(rest)));
},
inserted: function inserted() {
autoHeigth.apply(undefined, arguments);
},
update: function update() {
autoHeigth.apply(undefined, arguments);
},
unbind: function unbind() {
window.removeEventListener('resize', listener);
}
};