UNPKG

react-flexigrid

Version:

A React table component designed to allow presenting millions of rows of data.

74 lines (58 loc) 2.37 kB
import translateDOMPositionXY from './dom/translateDOMPositionXY'; import _clamp from 'clamp'; export { _clamp as clamp }; import _deepEqual from 'lodash.isequal'; export { _deepEqual as deepEqual }; import _shallowEqual from 'shallowequal'; export { _shallowEqual as shallowEqual }; var functionReturnTrue = function functionReturnTrue() { return true; }; var functionReturnFalse = function functionReturnFalse() { return false; }; var nativeRequestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame || global.mozRequestAnimationFrame || global.oRequestAnimationFrame || global.msRequestAnimationFrame; export var cancelAnimationFrame = global.cancelAnimationFrame || global.webkitCancelAnimationFrame || global.mozCancelAnimationFrame || global.oCancelAnimationFrame || global.msCancelAnimationFrame || global.clearTimeout; var animationFrameTime = 0; export var requestAnimationFrame = nativeRequestAnimationFrame || function (callback) { var currTime = Date.now(); var timeDelay = Math.max(0, 16 - (currTime - animationFrameTime)); animationFrameTime = currTime + timeDelay; return global.setTimeout(function () { callback(Date.now()); }, timeDelay); }; export function translateDOMPosition(style, x, y) { var initialRender = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; if (initialRender) { style.left = x + 'px'; style.top = y + 'px'; } else { translateDOMPositionXY(style, x, y); } } export function debounce(func, wait, context) { var setTimeoutFunc = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : setTimeout; var clearTimeoutFunc = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : clearTimeout; var timeout = void 0; var debouncer = function debouncer() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } debouncer.reset(); var callback = function callback() { func.apply(context, args); }; timeout = setTimeoutFunc(callback, wait); }; debouncer.reset = function () { clearTimeoutFunc(timeout); }; return debouncer; } export function getJudgeFunction(fn) { if (typeof handleScrollX !== 'function') { return fn ? functionReturnTrue : functionReturnFalse; } return fn; }