You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
729 B
30 lines
729 B
10 months ago
|
'use strict';
|
||
|
|
||
|
exports.__esModule = true;
|
||
|
|
||
|
var _dom = require('element-ui/lib/utils/dom');
|
||
|
|
||
|
exports.default = {
|
||
|
bind: function bind(el, binding, vnode) {
|
||
|
var interval = null;
|
||
|
var startTime = void 0;
|
||
|
var handler = function handler() {
|
||
|
return vnode.context[binding.expression].apply();
|
||
|
};
|
||
|
var clear = function clear() {
|
||
|
if (Date.now() - startTime < 100) {
|
||
|
handler();
|
||
|
}
|
||
|
clearInterval(interval);
|
||
|
interval = null;
|
||
|
};
|
||
|
|
||
|
(0, _dom.on)(el, 'mousedown', function (e) {
|
||
|
if (e.button !== 0) return;
|
||
|
startTime = Date.now();
|
||
|
(0, _dom.once)(document, 'mouseup', clear);
|
||
|
clearInterval(interval);
|
||
|
interval = setInterval(handler, 100);
|
||
|
});
|
||
|
}
|
||
|
};
|