NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/ant-design-vue/es/vc-align/util.js
2023-09-14 14:47:11 +08:00

53 lines
1.2 KiB
Java

import _typeof from 'babel-runtime/helpers/typeof';
import contains from '../vc-util/Dom/contains';
export function buffer(fn, ms) {
var timer = void 0;
function clear() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
function bufferFn() {
clear();
timer = setTimeout(fn, ms);
}
bufferFn.clear = clear;
return bufferFn;
}
export function isSamePoint(prev, next) {
if (prev === next) return true;
if (!prev || !next) return false;
if ('pageX' in next && 'pageY' in next) {
return prev.pageX === next.pageX && prev.pageY === next.pageY;
}
if ('clientX' in next && 'clientY' in next) {
return prev.clientX === next.clientX && prev.clientY === next.clientY;
}
return false;
}
export function isWindow(obj) {
return obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj.window === obj;
}
export function isSimilarValue(val1, val2) {
var int1 = Math.floor(val1);
var int2 = Math.floor(val2);
return Math.abs(int1 - int2) <= 1;
}
export function restoreFocus(activeElement, container) {
// Focus back if is in the container
if (activeElement !== document.activeElement && contains(container, activeElement)) {
activeElement.focus();
}
}