UNPKG

rmc-list-view

Version:
40 lines (37 loc) 790 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOffsetTop = getOffsetTop; exports._event = _event; exports.throttle = throttle; function getOffsetTop(elem) { var offsetTop = 0; do { if (!isNaN(elem.offsetTop)) { offsetTop += elem.offsetTop; } } while (elem = elem.offsetParent); return offsetTop; } function _event(e) { if (e.touches && e.touches.length) { return e.touches[0]; } if (e.changedTouches && e.changedTouches.length) { return e.changedTouches[0]; } return e; } function throttle(fn, delay) { var allowSample = true; return function (e) { if (allowSample) { allowSample = false; setTimeout(function () { allowSample = true; }, delay); fn(e); } }; }