Comparing version 0.0.1-beta.15 to 0.0.1-beta.16
42
index.js
@@ -1,40 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "useDebounce", { | ||
enumerable: true, | ||
get: function get() { | ||
return _useDebounce.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useDrag", { | ||
enumerable: true, | ||
get: function get() { | ||
return _useDrag.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useKeyPress", { | ||
enumerable: true, | ||
get: function get() { | ||
return _useKeypress.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useThrottle", { | ||
enumerable: true, | ||
get: function get() { | ||
return _useThrottle.default; | ||
} | ||
}); | ||
var _useDebounce = _interopRequireDefault(require("./use-debounce")); | ||
var _useDrag = _interopRequireDefault(require("./use-drag")); | ||
var _useKeypress = _interopRequireDefault(require("./use-keypress")); | ||
var _useThrottle = _interopRequireDefault(require("./use-throttle")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3JlY2lwZXMvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7O0FBQ0E7O0FBQ0E7O0FBQ0EiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQge2RlZmF1bHQgYXMgdXNlRGVib3VuY2V9IGZyb20gJy4vdXNlLWRlYm91bmNlJ1xuZXhwb3J0IHtkZWZhdWx0IGFzIHVzZURyYWd9IGZyb20gJy4vdXNlLWRyYWcnXG5leHBvcnQge2RlZmF1bHQgYXMgdXNlS2V5UHJlc3N9IGZyb20gJy4vdXNlLWtleXByZXNzJ1xuZXhwb3J0IHtkZWZhdWx0IGFzIHVzZVRocm90dGxlfSBmcm9tICcuL3VzZS10aHJvdHRsZSdcbiJdfQ== | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"useDebounce",{enumerable:true,get:function get(){return _useDebounce.default}});Object.defineProperty(exports,"useDrag",{enumerable:true,get:function get(){return _useDrag.default}});Object.defineProperty(exports,"useKeyPress",{enumerable:true,get:function get(){return _useKeypress.default}});Object.defineProperty(exports,"useThrottle",{enumerable:true,get:function get(){return _useThrottle.default}});var _useDebounce=_interopRequireDefault(require("./use-debounce"));var _useDrag=_interopRequireDefault(require("./use-drag"));var _useKeypress=_interopRequireDefault(require("./use-keypress"));var _useThrottle=_interopRequireDefault(require("./use-throttle"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3JlY2lwZXMvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjBmQUFBLG1FQUNBLDJEQUNBLG1FQUNBLG1FIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHtkZWZhdWx0IGFzIHVzZURlYm91bmNlfSBmcm9tICcuL3VzZS1kZWJvdW5jZSdcbmV4cG9ydCB7ZGVmYXVsdCBhcyB1c2VEcmFnfSBmcm9tICcuL3VzZS1kcmFnJ1xuZXhwb3J0IHtkZWZhdWx0IGFzIHVzZUtleVByZXNzfSBmcm9tICcuL3VzZS1rZXlwcmVzcydcbmV4cG9ydCB7ZGVmYXVsdCBhcyB1c2VUaHJvdHRsZX0gZnJvbSAnLi91c2UtdGhyb3R0bGUnXG4iXX0= |
{ | ||
"name": "hook-book", | ||
"version": "0.0.1-beta.15", | ||
"version": "0.0.1-beta.16", | ||
"description": "A collection of custom React Hooks", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,63 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = useDebounce; | ||
var _react = require("react"); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function useDebounce(value, delay) { | ||
var _useState = (0, _react.useState)(value), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
debouncedValue = _useState2[0], | ||
setDebouncedValue = _useState2[1]; // Use queue & timeout to power the update loop. | ||
var queue = (0, _react.useRef)(null); | ||
var timeout = (0, _react.useRef)(null); // Clear the timeout on component unmount. | ||
(0, _react.useEffect)(function () { | ||
return function () { | ||
return clearTimeout(timeout.current); | ||
}; | ||
}, []); | ||
(0, _react.useEffect)(function () { | ||
// Avoid triggering the update loop on the component mount lifecycle. | ||
// Use the absence of the queue reference to indentify this case. | ||
if (!queue.current) { | ||
queue.current = []; | ||
return; | ||
} | ||
var updateValue = function updateValue() { | ||
if (!queue.current.length) { | ||
timeout.current = clearTimeout(timeout.current); | ||
return; | ||
} // Set the value as the latest update in the queue and clear | ||
// the prior queued updates. | ||
var debouncedValue = queue.current.pop(); | ||
queue.current = []; | ||
timeout.current = setTimeout(updateValue, delay); | ||
setDebouncedValue(debouncedValue); | ||
}; // Add every value change to the update | ||
queue.current.push(value); // If there is currently a change queued to occur, we do nothing. | ||
// Otherwise, trigger the update loop by setting the timeout. | ||
timeout.current = timeout.current || setTimeout(updateValue, 0); | ||
}, [value]); | ||
return debouncedValue; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,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AgICAgIHRpbWVvdXQuY3VycmVudCA9IHNldFRpbWVvdXQodXBkYXRlVmFsdWUsIGRlbGF5KVxuICAgICAgICAgICAgc2V0RGVib3VuY2VkVmFsdWUoZGVib3VuY2VkVmFsdWUpXG4gICAgICAgIH1cblxuICAgICAgICAvLyBBZGQgZXZlcnkgdmFsdWUgY2hhbmdlIHRvIHRoZSB1cGRhdGVcbiAgICAgICAgcXVldWUuY3VycmVudC5wdXNoKHZhbHVlKVxuXG4gICAgICAgIC8vIElmIHRoZXJlIGlzIGN1cnJlbnRseSBhIGNoYW5nZSBxdWV1ZWQgdG8gb2NjdXIsIHdlIGRvIG5vdGhpbmcuXG4gICAgICAgIC8vIE90aGVyd2lzZSwgdHJpZ2dlciB0aGUgdXBkYXRlIGxvb3AgYnkgc2V0dGluZyB0aGUgdGltZW91dC5cbiAgICAgICAgdGltZW91dC5jdXJyZW50ID0gdGltZW91dC5jdXJyZW50IHx8IHNldFRpbWVvdXQodXBkYXRlVmFsdWUsIDApXG4gICAgfSwgW3ZhbHVlXSlcblxuICAgIHJldHVybiBkZWJvdW5jZWRWYWx1ZVxufVxuIl19 | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=useDebounce;var _react=require("react");function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function useDebounce(value,delay){var _useState=(0,_react.useState)(value),_useState2=_slicedToArray(_useState,2),debouncedValue=_useState2[0],setDebouncedValue=_useState2[1];// Use queue & timeout to power the update loop. | ||
var queue=(0,_react.useRef)(null);var timeout=(0,_react.useRef)(null);// Clear the timeout on component unmount. | ||
(0,_react.useEffect)(function(){return function(){return clearTimeout(timeout.current)}},[]);(0,_react.useEffect)(function(){// Avoid triggering the update loop on the component mount lifecycle. | ||
// Use the absence of the queue reference to indentify this case. | ||
if(!queue.current){queue.current=[];return}var updateValue=function updateValue(){if(!queue.current.length){timeout.current=clearTimeout(timeout.current);return}// Set the value as the latest update in the queue and clear | ||
// the prior queued updates. | ||
var debouncedValue=queue.current.pop();queue.current=[];timeout.current=setTimeout(updateValue,delay);setDebouncedValue(debouncedValue)};// Add every value change to the update | ||
queue.current.push(value);// If there is currently a change queued to occur, we do nothing. | ||
// Otherwise, trigger the update loop by setting the timeout. | ||
timeout.current=timeout.current||setTimeout(updateValue,0)},[value]);return debouncedValue} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWRlYm91bmNlL2luZGV4LmpzIl0sIm5hbWVzIjpbInVzZURlYm91bmNlIiwidmFsdWUiLCJkZWxheSIsImRlYm91bmNlZFZhbHVlIiwic2V0RGVib3VuY2VkVmFsdWUiLCJxdWV1ZSIsInRpbWVvdXQiLCJjbGVhclRpbWVvdXQiLCJjdXJyZW50IiwidXBkYXRlVmFsdWUiLCJsZW5ndGgiLCJwb3AiLCJzZXRUaW1lb3V0IiwicHVzaCJdLCJtYXBwaW5ncyI6ImtHQUFBLDRCLGltQkFFZSxRQUFTQSxDQUFBQSxXQUFULENBQXFCQyxLQUFyQixDQUE0QkMsS0FBNUIsQ0FBbUMsZUFDRixvQkFBU0QsS0FBVCxDQURFLHdDQUN2Q0UsY0FEdUMsZUFDdkJDLGlCQUR1QixlQUU5QztBQUNBLEdBQU1DLENBQUFBLEtBQUssQ0FBRyxrQkFBTyxJQUFQLENBQWQsQ0FDQSxHQUFNQyxDQUFBQSxPQUFPLENB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ID0gY2xlYXJUaW1lb3V0KHRpbWVvdXQuY3VycmVudClcbiAgICAgICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gU2V0IHRoZSB2YWx1ZSBhcyB0aGUgbGF0ZXN0IHVwZGF0ZSBpbiB0aGUgcXVldWUgYW5kIGNsZWFyXG4gICAgICAgICAgICAvLyB0aGUgcHJpb3IgcXVldWVkIHVwZGF0ZXMuXG4gICAgICAgICAgICBjb25zdCBkZWJvdW5jZWRWYWx1ZSA9IHF1ZXVlLmN1cnJlbnQucG9wKClcbiAgICAgICAgICAgIHF1ZXVlLmN1cnJlbnQgPSBbXVxuICAgICAgICAgICAgdGltZW91dC5jdXJyZW50ID0gc2V0VGltZW91dCh1cGRhdGVWYWx1ZSwgZGVsYXkpXG4gICAgICAgICAgICBzZXREZWJvdW5jZWRWYWx1ZShkZWJvdW5jZWRWYWx1ZSlcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEFkZCBldmVyeSB2YWx1ZSBjaGFuZ2UgdG8gdGhlIHVwZGF0ZVxuICAgICAgICBxdWV1ZS5jdXJyZW50LnB1c2godmFsdWUpXG5cbiAgICAgICAgLy8gSWYgdGhlcmUgaXMgY3VycmVudGx5IGEgY2hhbmdlIHF1ZXVlZCB0byBvY2N1ciwgd2UgZG8gbm90aGluZy5cbiAgICAgICAgLy8gT3RoZXJ3aXNlLCB0cmlnZ2VyIHRoZSB1cGRhdGUgbG9vcCBieSBzZXR0aW5nIHRoZSB0aW1lb3V0LlxuICAgICAgICB0aW1lb3V0LmN1cnJlbnQgPSB0aW1lb3V0LmN1cnJlbnQgfHwgc2V0VGltZW91dCh1cGRhdGVWYWx1ZSwgMClcbiAgICB9LCBbdmFsdWVdKVxuXG4gICAgcmV0dXJuIGRlYm91bmNlZFZhbHVlXG59XG4iXX0= |
@@ -1,90 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = useDrag; | ||
var _react = require("react"); | ||
var _reducer = _interopRequireWildcard(require("./reducer")); | ||
var _utils = require("../utils"); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var DRAG_START_EVENTS = ['mousedown', 'touchstart']; | ||
var DRAG_EVENTS = ['mousemove', 'touchmove']; | ||
var DRAG_END_EVENTS = ['mouseup', 'touchcancel', 'touchend']; | ||
function useDrag(ref) { | ||
var _useReducer = (0, _react.useReducer)(_reducer.default, _reducer.initialState), | ||
_useReducer2 = _slicedToArray(_useReducer, 2), | ||
state = _useReducer2[0], | ||
dispatch = _useReducer2[1]; | ||
var isDragging = state.isDragging; | ||
var onDragStart = function onDragStart(event) { | ||
return dispatch({ | ||
type: 'DRAG_START', | ||
payload: { | ||
event: event | ||
} | ||
}); | ||
}; | ||
var onDrag = function onDrag(event) { | ||
return dispatch({ | ||
type: 'DRAG', | ||
payload: { | ||
event: event | ||
} | ||
}); | ||
}; | ||
var onDragEnd = function onDragEnd(event) { | ||
return dispatch({ | ||
type: 'DRAG_END', | ||
payload: { | ||
event: event | ||
} | ||
}); | ||
}; | ||
(0, _react.useEffect)(function () { | ||
// Listen for events indicating that dragging has begun | ||
(0, _utils.bulkAddEventListener)(ref.current, DRAG_START_EVENTS, onDragStart); | ||
return function () { | ||
return (0, _utils.bulkRemoveEventListener)(ref.current, DRAG_START_EVENTS, onDragStart); | ||
}; | ||
}, [ref.current]); | ||
(0, _react.useEffect)(function () { | ||
// Only need to listen for drag and drag end events when dragging has started | ||
if (isDragging) { | ||
(0, _utils.bulkAddEventListener)(window, DRAG_EVENTS, onDrag); | ||
(0, _utils.bulkAddEventListener)(window, DRAG_END_EVENTS, onDragEnd); | ||
window.addEventListener('blur', onDragEnd); | ||
} else { | ||
(0, _utils.bulkRemoveEventListener)(window, DRAG_EVENTS, onDrag); | ||
(0, _utils.bulkRemoveEventListener)(window, DRAG_END_EVENTS, onDragEnd); | ||
window.removeEventListener('blur', onDragEnd); | ||
} | ||
return function () { | ||
(0, _utils.bulkRemoveEventListener)(window, DRAG_EVENTS, onDrag); | ||
(0, _utils.bulkRemoveEventListener)(window, DRAG_END_EVENTS, onDragEnd); | ||
window.removeEventListener('blur', onDragEnd); | ||
}; | ||
}, [isDragging]); | ||
return state; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWRyYWcvaW5kZXguanMiXSwibmFtZXMiOlsiRFJBR19TVEFSVF9FVkVOVFMiLCJEUkFHX0VWRU5UUyIsIkRSQUdfRU5EX0VWRU5UUyIsInVzZURyYWciLCJyZWYiLCJyZWR1Y2VyIiwiaW5pdGlhbFN0YXRlIiwic3RhdGUiLCJkaXNwYXRjaCIsImlzRHJhZ2dpbmciLCJvbkRyYWdTdGFydCIsImV2ZW50IiwidHlwZSIsInBheWxvYWQiLCJvbkRyYWciLCJvbkRyYWdFbmQiLCJjdXJyZW50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udExpc3RlbmVyKHdpbmRvdywgRFJBR19FTkRfRVZFTlRTLCBvbkRyYWdFbmQpXG4gICAgICAgICAgICB3aW5kb3cucmVtb3ZlRXZlbnRMaXN0ZW5lcignYmx1cicsIG9uRHJhZ0VuZClcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiAoKSA9PiB7XG4gICAgICAgICAgICBidWxrUmVtb3ZlRXZlbnRMaXN0ZW5lcih3aW5kb3csIERSQUdfRVZFTlRTLCBvbkRyYWcpXG4gICAgICAgICAgICBidWxrUmVtb3ZlRXZlbnRMaXN0ZW5lcih3aW5kb3csIERSQUdfRU5EX0VWRU5UUywgb25EcmFnRW5kKVxuICAgICAgICAgICAgd2luZG93LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2JsdXInLCBvbkRyYWdFbmQpXG4gICAgICAgIH1cbiAgICB9LCBbaXNEcmFnZ2luZ10pXG5cbiAgICByZXR1cm4gc3RhdGVcbn1cbiJdfQ== | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=useDrag;var _react=require("react");var _reducer=_interopRequireWildcard(require("./reducer"));var _utils=require("../utils");function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):{};if(desc.get||desc.set){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}}newObj.default=obj;return newObj}}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}var DRAG_START_EVENTS=["mousedown","touchstart"];var DRAG_EVENTS=["mousemove","touchmove"];var DRAG_END_EVENTS=["mouseup","touchcancel","touchend"];function useDrag(ref){var _useReducer=(0,_react.useReducer)(_reducer.default,_reducer.initialState),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var isDragging=state.isDragging;var onDragStart=function onDragStart(event){return dispatch({type:"DRAG_START",payload:{event:event}})};var onDrag=function onDrag(event){return dispatch({type:"DRAG",payload:{event:event}})};var onDragEnd=function onDragEnd(event){return dispatch({type:"DRAG_END",payload:{event:event}})};(0,_react.useEffect)(function(){// Listen for events indicating that dragging has begun | ||
(0,_utils.bulkAddEventListener)(ref.current,DRAG_START_EVENTS,onDragStart);return function(){return(0,_utils.bulkRemoveEventListener)(ref.current,DRAG_START_EVENTS,onDragStart)}},[ref.current]);(0,_react.useEffect)(function(){// Only need to listen for drag and drag end events when dragging has started | ||
if(isDragging){(0,_utils.bulkAddEventListener)(window,DRAG_EVENTS,onDrag);(0,_utils.bulkAddEventListener)(window,DRAG_END_EVENTS,onDragEnd);window.addEventListener("blur",onDragEnd)}else{(0,_utils.bulkRemoveEventListener)(window,DRAG_EVENTS,onDrag);(0,_utils.bulkRemoveEventListener)(window,DRAG_END_EVENTS,onDragEnd);window.removeEventListener("blur",onDragEnd)}return function(){(0,_utils.bulkRemoveEventListener)(window,DRAG_EVENTS,onDrag);(0,_utils.bulkRemoveEventListener)(window,DRAG_END_EVENTS,onDragEnd);window.removeEventListener("blur",onDragEnd)}},[isDragging]);return state} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWRyYWcvaW5kZXguanMiXSwibmFtZXMiOlsiRFJBR19TVEFSVF9FVkVOVFMiLCJEUkF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ICAgICAgICBidWxrUmVtb3ZlRXZlbnRMaXN0ZW5lcih3aW5kb3csIERSQUdfRVZFTlRTLCBvbkRyYWcpXG4gICAgICAgICAgICBidWxrUmVtb3ZlRXZlbnRMaXN0ZW5lcih3aW5kb3csIERSQUdfRU5EX0VWRU5UUywgb25EcmFnRW5kKVxuICAgICAgICAgICAgd2luZG93LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2JsdXInLCBvbkRyYWdFbmQpXG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgICAgICAgYnVsa1JlbW92ZUV2ZW50TGlzdGVuZXIod2luZG93LCBEUkFHX0VWRU5UUywgb25EcmFnKVxuICAgICAgICAgICAgYnVsa1JlbW92ZUV2ZW50TGlzdGVuZXIod2luZG93LCBEUkFHX0VORF9FVkVOVFMsIG9uRHJhZ0VuZClcbiAgICAgICAgICAgIHdpbmRvdy5yZW1vdmVFdmVudExpc3RlbmVyKCdibHVyJywgb25EcmFnRW5kKVxuICAgICAgICB9XG4gICAgfSwgW2lzRHJhZ2dpbmddKVxuXG4gICAgcmV0dXJuIHN0YXRlXG59XG4iXX0= |
@@ -1,58 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.initialState = void 0; | ||
var _utils = require("../utils"); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var initialState = { | ||
isDragging: false | ||
}; | ||
exports.initialState = initialState; | ||
var _default = function _default(state, action) { | ||
switch (action.type) { | ||
case 'DRAG_START': | ||
{ | ||
var _getPointerPosition = (0, _utils.getPointerPosition)(action.payload.event), | ||
x = _getPointerPosition.x, | ||
y = _getPointerPosition.y; | ||
return !state.isDragging ? { | ||
isDragging: true, | ||
startX: x, | ||
startY: y, | ||
x: x, | ||
y: y | ||
} : state; | ||
} | ||
case 'DRAG': | ||
{ | ||
var _getPointerPosition2 = (0, _utils.getPointerPosition)(action.payload.event), | ||
_x = _getPointerPosition2.x, | ||
_y = _getPointerPosition2.y; | ||
var positionChanged = _x !== state.x || _y !== state.y; | ||
return state.isDragging && positionChanged ? _objectSpread({}, state, { | ||
x: _x, | ||
y: _y | ||
}) : state; | ||
} | ||
case 'DRAG_END': | ||
return initialState; | ||
default: | ||
return state; | ||
} | ||
}; | ||
exports.default = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWRyYWcvcmVkdWNlci5qcyJdLCJuYW1lcyI6WyJpbml0aWFsU3RhdGUiLCJpc0RyYWdnaW5nIiwic3RhdGUiLCJhY3Rpb24iLCJ0eXBlIiwicGF5bG9hZCIsImV2ZW50IiwieCIsInkiLCJzdGFydFgiLCJzdGFydFkiLCJwb3NpdGlvbkNoYW5nZWQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7Ozs7O0FBRU8sSUFBTUEsWUFBWSxHQUFHO0FBQ3hCQyxFQUFBQSxVQUFVLEVBQUU7QUFEWSxDQUFyQjs7O2VBSVEsa0JBQUNDLEtBQUQsRUFBUUMsTUFBUixFQUFtQjtBQUM5QixVQUFRQSxNQUFNLENBQUNDLElBQWY7QUFDSSxTQUFLLFlBQUw7QUFBbUI7QUFBQSxrQ0FDQSwrQkFBbUJELE1BQU0sQ0FBQ0UsT0FBUCxDQUFlQyxLQUFsQyxDQURBO0FBQUEsWUFDUkMsQ0FE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mV4cG9ydCBkZWZhdWx0IChzdGF0ZSwgYWN0aW9uKSA9PiB7XG4gICAgc3dpdGNoIChhY3Rpb24udHlwZSkge1xuICAgICAgICBjYXNlICdEUkFHX1NUQVJUJzoge1xuICAgICAgICAgICAgY29uc3Qge3gsIHl9ID0gZ2V0UG9pbnRlclBvc2l0aW9uKGFjdGlvbi5wYXlsb2FkLmV2ZW50KVxuICAgICAgICAgICAgcmV0dXJuICFzdGF0ZS5pc0RyYWdnaW5nID8ge2lzRHJhZ2dpbmc6IHRydWUsIHN0YXJ0WDogeCwgc3RhcnRZOiB5LCB4LCB5fSA6IHN0YXRlXG4gICAgICAgIH1cblxuICAgICAgICBjYXNlICdEUkFHJzoge1xuICAgICAgICAgICAgY29uc3Qge3gsIHl9ID0gZ2V0UG9pbnRlclBvc2l0aW9uKGFjdGlvbi5wYXlsb2FkLmV2ZW50KVxuICAgICAgICAgICAgY29uc3QgcG9zaXRpb25DaGFuZ2VkID0geCAhPT0gc3RhdGUueCB8fCB5ICE9PSBzdGF0ZS55XG4gICAgICAgICAgICByZXR1cm4gc3RhdGUuaXNEcmFnZ2luZyAmJiBwb3NpdGlvbkNoYW5nZWQgPyB7Li4uc3RhdGUsIHgsIHl9IDogc3RhdGVcbiAgICAgICAgfVxuXG4gICAgICAgIGNhc2UgJ0RSQUdfRU5EJzpcbiAgICAgICAgICAgIHJldHVybiBpbml0aWFsU3RhdGVcblxuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgcmV0dXJuIHN0YXRlXG4gICAgfVxufVxuIl19 | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.initialState=void 0;var _utils=require("../utils");function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_defineProperty(target,key,source[key])})}return target}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}var initialState={isDragging:false};exports.initialState=initialState;var _default=function _default(state,action){switch(action.type){case"DRAG_START":{var _getPointerPosition=(0,_utils.getPointerPosition)(action.payload.event),x=_getPointerPosition.x,y=_getPointerPosition.y;return!state.isDragging?{isDragging:true,startX:x,startY:y,x:x,y:y}:state}case"DRAG":{var _getPointerPosition2=(0,_utils.getPointerPosition)(action.payload.event),_x=_getPointerPosition2.x,_y=_getPointerPosition2.y;var positionChanged=_x!==state.x||_y!==state.y;return state.isDragging&&positionChanged?_objectSpread({},state,{x:_x,y:_y}):state}case"DRAG_END":return initialState;default:return state;}};exports.default=_default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWRyYWcvcmVkdWNlci5qcyJdLCJuYW1lcyI6WyJpbml0aWFsU3RhdGUiLCJpc0RyYWdnaW5nIiwic3RhdGUiLCJhY3Rpb24iLCJ0eXBlIiwicGF5bG9hZCIsImV2ZW50IiwieCIsInkiLCJzdGFydFgiLCJzdGFydFkiLCJwb3NpdGlvbkNoYW5nZWQiXSwibWFwcGluZ3MiOiJrSEFBQSwrQixpbUJBRU8sR0FBTUEsQ0FBQUEsWUFBWSxDQUFHLENBQ3hCQyxVQUFVLENBQUUsS0FEWSxDQUFyQixDLCtDQUlRLGtCQUFDQyxLQUFELENBQVFDLE1BQVIsQ0FBbUIsQ0FDOUIsT0FBUUEsTUFBTSxDQUFDQyxJQUFmLEVBQ0ksSUFBSyxZQUFMLENBQW1CLHlCQUNBLDhCQUFtQkQsTUFBTSxDQUFDRSxPQUFQLENBQWVDLEtBQWxDLENBREEsQ0FDUkMsQ0FEUSxxQkFDUkEsQ0FEUSxDQUNMQyxDQURLLHFCQUNMQSxDQURLLENBR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19TVEFSVCc6IHtcbiAgICAgICAgICAgIGNvbnN0IHt4LCB5fSA9IGdldFBvaW50ZXJQb3NpdGlvbihhY3Rpb24ucGF5bG9hZC5ldmVudClcbiAgICAgICAgICAgIHJldHVybiAhc3RhdGUuaXNEcmFnZ2luZyA/IHtpc0RyYWdnaW5nOiB0cnVlLCBzdGFydFg6IHgsIHN0YXJ0WTogeSwgeCwgeX0gOiBzdGF0ZVxuICAgICAgICB9XG5cbiAgICAgICAgY2FzZSAnRFJBRyc6IHtcbiAgICAgICAgICAgIGNvbnN0IHt4LCB5fSA9IGdldFBvaW50ZXJQb3NpdGlvbihhY3Rpb24ucGF5bG9hZC5ldmVudClcbiAgICAgICAgICAgIGNvbnN0IHBvc2l0aW9uQ2hhbmdlZCA9IHggIT09IHN0YXRlLnggfHwgeSAhPT0gc3RhdGUueVxuICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmlzRHJhZ2dpbmcgJiYgcG9zaXRpb25DaGFuZ2VkID8gey4uLnN0YXRlLCB4LCB5fSA6IHN0YXRlXG4gICAgICAgIH1cblxuICAgICAgICBjYXNlICdEUkFHX0VORCc6XG4gICAgICAgICAgICByZXR1cm4gaW5pdGlhbFN0YXRlXG5cbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHJldHVybiBzdGF0ZVxuICAgIH1cbn1cbiJdfQ== |
@@ -1,64 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = useKeyPress; | ||
var _react = require("react"); | ||
var _reducer = _interopRequireWildcard(require("./reducer")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function useKeyPress() { | ||
// Use the useReducer hook instead of useState, since the resulting states | ||
// depend on the previous. | ||
var _useReducer = (0, _react.useReducer)(_reducer.default, _reducer.initialState), | ||
_useReducer2 = _slicedToArray(_useReducer, 2), | ||
keyPressed = _useReducer2[0], | ||
dispatch = _useReducer2[1]; | ||
var onKeyDown = function onKeyDown(event) { | ||
return dispatch({ | ||
type: 'KEY_DOWN', | ||
key: event.key | ||
}); | ||
}; | ||
var onKeyUp = function onKeyUp(event) { | ||
return dispatch({ | ||
type: 'KEY_UP', | ||
key: event.key | ||
}); | ||
}; // Need to reset active keys when the window loses focus, otherwise the keyup | ||
// event never fires & remain 'active' when the window regains focus | ||
var onBlur = function onBlur() { | ||
return dispatch({ | ||
type: 'RESET' | ||
}); | ||
}; | ||
(0, _react.useEffect)(function () { | ||
document.addEventListener('keydown', onKeyDown); | ||
document.addEventListener('keyup', onKeyUp); | ||
window.addEventListener('blur', onBlur); | ||
return function () { | ||
document.removeEventListener('keydown', onKeyDown); | ||
document.removeEventListener('keyup', onKeyUp); | ||
window.removeEventListener('blur', onBlur); | ||
}; | ||
}); | ||
return keyPressed; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdX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ZX0RPV04nLCBrZXk6IGV2ZW50LmtleX0pXG4gICAgY29uc3Qgb25LZXlVcCA9IGV2ZW50ID0+IGRpc3BhdGNoKHt0eXBlOiAnS0VZX1VQJywga2V5OiBldmVudC5rZXl9KVxuICAgIC8vIE5lZWQgdG8gcmVzZXQgYWN0aXZlIGtleXMgd2hlbiB0aGUgd2luZG93IGxvc2VzIGZvY3VzLCBvdGhlcndpc2UgdGhlIGtleXVwXG4gICAgLy8gZXZlbnQgbmV2ZXIgZmlyZXMgJiByZW1haW4gJ2FjdGl2ZScgd2hlbiB0aGUgd2luZG93IHJlZ2FpbnMgZm9jdXNcbiAgICBjb25zdCBvbkJsdXIgPSAoKSA9PiBkaXNwYXRjaCh7dHlwZTogJ1JFU0VUJ30pXG5cbiAgICB1c2VFZmZlY3QoKCkgPT4ge1xuICAgICAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdrZXlkb3duJywgb25LZXlEb3duKVxuICAgICAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdrZXl1cCcsIG9uS2V5VXApXG4gICAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCdibHVyJywgb25CbHVyKVxuXG4gICAgICAgIHJldHVybiAoKSA9PiB7XG4gICAgICAgICAgICBkb2N1bWVudC5yZW1vdmVFdmVudExpc3RlbmVyKCdrZXlkb3duJywgb25LZXlEb3duKVxuICAgICAgICAgICAgZG9jdW1lbnQucmVtb3ZlRXZlbnRMaXN0ZW5lcigna2V5dXAnLCBvbktleVVwKVxuICAgICAgICAgICAgd2luZG93LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2JsdXInLCBvbkJsdXIpXG4gICAgICAgIH1cbiAgICB9KVxuXG4gICAgcmV0dXJuIGtleVByZXNzZWRcbn1cbiJdfQ== | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=useKeyPress;var _react=require("react");var _reducer=_interopRequireWildcard(require("./reducer"));function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):{};if(desc.get||desc.set){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}}newObj.default=obj;return newObj}}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function useKeyPress(){// Use the useReducer hook instead of useState, since the resulting states | ||
// depend on the previous. | ||
var _useReducer=(0,_react.useReducer)(_reducer.default,_reducer.initialState),_useReducer2=_slicedToArray(_useReducer,2),keyPressed=_useReducer2[0],dispatch=_useReducer2[1];var onKeyDown=function onKeyDown(event){return dispatch({type:"KEY_DOWN",key:event.key})};var onKeyUp=function onKeyUp(event){return dispatch({type:"KEY_UP",key:event.key})};// Need to reset active keys when the window loses focus, otherwise the keyup | ||
// event never fires & remain 'active' when the window regains focus | ||
var onBlur=function onBlur(){return dispatch({type:"RESET"})};(0,_react.useEffect)(function(){document.addEventListener("keydown",onKeyDown);document.addEventListener("keyup",onKeyUp);window.addEventListener("blur",onBlur);return function(){document.removeEventListener("keydown",onKeyDown);document.removeEventListener("keyup",onKeyUp);window.removeEventListener("blur",onBlur)}});return keyPressed} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWtleXByZXNzL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AgLy8gTmVlZCB0byByZXNldCBhY3RpdmUga2V5cyB3aGVuIHRoZSB3aW5kb3cgbG9zZXMgZm9jdXMsIG90aGVyd2lzZSB0aGUga2V5dXBcbiAgICAvLyBldmVudCBuZXZlciBmaXJlcyAmIHJlbWFpbiAnYWN0aXZlJyB3aGVuIHRoZSB3aW5kb3cgcmVnYWlucyBmb2N1c1xuICAgIGNvbnN0IG9uQmx1ciA9ICgpID0+IGRpc3BhdGNoKHt0eXBlOiAnUkVTRVQnfSlcblxuICAgIHVzZUVmZmVjdCgoKSA9PiB7XG4gICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoJ2tleWRvd24nLCBvbktleURvd24pXG4gICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoJ2tleXVwJywgb25LZXlVcClcbiAgICAgICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoJ2JsdXInLCBvbkJsdXIpXG5cbiAgICAgICAgcmV0dXJuICgpID0+IHtcbiAgICAgICAgICAgIGRvY3VtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2tleWRvd24nLCBvbktleURvd24pXG4gICAgICAgICAgICBkb2N1bWVudC5yZW1vdmVFdmVudExpc3RlbmVyKCdrZXl1cCcsIG9uS2V5VXApXG4gICAgICAgICAgICB3aW5kb3cucmVtb3ZlRXZlbnRMaXN0ZW5lcignYmx1cicsIG9uQmx1cilcbiAgICAgICAgfVxuICAgIH0pXG5cbiAgICByZXR1cm4ga2V5UHJlc3NlZFxufVxuIl19 |
@@ -1,47 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.initialState = void 0; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var initialState = {}; | ||
exports.initialState = initialState; | ||
var _default = function _default(state, action) { | ||
switch (action.type) { | ||
case 'KEY_DOWN': | ||
return !state[action.key] ? _objectSpread({}, state, _defineProperty({}, action.key, true)) : state; | ||
case 'KEY_UP': | ||
{ | ||
var isKeyPressed = state[action.key], | ||
newState = _objectWithoutProperties(state, [action.key].map(_toPropertyKey)); | ||
return isKeyPressed ? newState : state; | ||
} | ||
case 'RESET': | ||
return initialState; | ||
default: | ||
return state; | ||
} | ||
}; | ||
exports.default = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWtleXByZXNzL3JlZHVjZXIuanMiXSwibmFtZXMiOlsiaW5pdGlhbFN0YXRlIiwic3RhdGUiLCJhY3Rpb24iLCJ0eXBlIiwia2V5IiwiaXNLZXlQcmVzc2VkIiwibmV3U3RhdGUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFPLElBQU1BLFlBQVksR0FBRyxFQUFyQjs7O2VBRVEsa0JBQUNDLEtBQUQsRUFBUUMsTUFBUixFQUFtQjtBQUM5QixVQUFRQSxNQUFNLENBQUNDLElBQWY7QUFDSSxTQUFLLFVBQUw7QUFDSSxhQUFPLENBQUNGLEtBQUssQ0FBQ0MsTUFBTSxDQUFDRSxHQUFSLENBQU4scUJBQXlCSCxLQUF6QixzQkFBaUNDLE1BQU0sQ0FBQ0UsR0FBeEMsRUFBOEMsSUFBOUMsS0FBc0RILEtBQTdEOztBQUVKLFNBQUssUUFBTDtBQUFlO0FBQUEsWUFDVUksWUFEVixHQUN1Q0osS0FEdkMsQ0FDSEMsTUFBTSxDQUFDRSxHQURKO0FBQUEsWUFDMkJFLFFBRDNCLDRCQUN1Q0wsS0FEdkMsR0FDSEMsTUFBTSxDQUFDRSxHQURKOztBQUVYLGVBQU9DLFlBQVksR0FBR0MsUUFBSCxHQUFjTCxLQUFqQztBQUNIOztBQUVELFNBQUssT0FBTDtBQUNJLGFBQU9ELFlBQVA7O0FBRUo7QUFDSSxhQUFPQyxLQUFQO0FBYlI7QUFlSCxDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNvbnN0IGluaXRpYWxTdGF0ZSA9IHt9XG5cbmV4cG9ydCBkZWZhdWx0IChzdGF0ZSwgYWN0aW9uKSA9PiB7XG4gICAgc3dpdGNoIChhY3Rpb24udHlwZSkge1xuICAgICAgICBjYXNlICdLRVlfRE9XTic6XG4gICAgICAgICAgICByZXR1cm4gIXN0YXRlW2FjdGlvbi5rZXldID8gey4uLnN0YXRlLCBbYWN0aW9uLmtleV06IHRydWV9IDogc3RhdGVcblxuICAgICAgICBjYXNlICdLRVlfVVAnOiB7XG4gICAgICAgICAgICBjb25zdCB7W2FjdGlvbi5rZXldOiBpc0tleVByZXNzZWQsIC4uLm5ld1N0YXRlfSA9IHN0YXRlXG4gICAgICAgICAgICByZXR1cm4gaXNLZXlQcmVzc2VkID8gbmV3U3RhdGUgOiBzdGF0ZVxuICAgICAgICB9XG5cbiAgICAgICAgY2FzZSAnUkVTRVQnOlxuICAgICAgICAgICAgcmV0dXJuIGluaXRpYWxTdGF0ZVxuXG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICByZXR1cm4gc3RhdGVcbiAgICB9XG59XG4iXX0= | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.initialState=void 0;function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key)}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return(hint==="string"?String:Number)(input)}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_defineProperty(target,key,source[key])})}return target}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}var initialState={};exports.initialState=initialState;var _default=function _default(state,action){switch(action.type){case"KEY_DOWN":return!state[action.key]?_objectSpread({},state,_defineProperty({},action.key,true)):state;case"KEY_UP":{var isKeyPressed=state[action.key],newState=_objectWithoutProperties(state,[action.key].map(_toPropertyKey));return isKeyPressed?newState:state}case"RESET":return initialState;default:return state;}};exports.default=_default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLWtleXByZXNzL3JlZHVjZXIuanMiXSwibmFtZXMiOlsiaW5pdGlhbFN0YXRlIiwic3RhdGUiLCJhY3Rpb24iLCJ0eXBlIiwia2V5IiwiaXNLZXlQcmVzc2VkIiwibmV3U3RhdGUiXSwibWFwcGluZ3MiOiJzb0VBQU8sR0FBTUEsQ0FBQUEsWUFBWSxDQUFHLEVBQXJCLEMsK0NBRVEsa0JBQUNDLEtBQUQsQ0FBUUMsTUFBUixDQ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nOlxuICAgICAgICAgICAgcmV0dXJuIGluaXRpYWxTdGF0ZVxuXG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICByZXR1cm4gc3RhdGVcbiAgICB9XG59XG4iXX0= |
@@ -1,59 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = useThrottle; | ||
var _react = require("react"); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function useThrottle(value, delay) { | ||
var _useState = (0, _react.useState)(value), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
throttledValue = _useState2[0], | ||
setThrottledValue = _useState2[1]; // Use queue & timeout to power the update loop. | ||
var queue = (0, _react.useRef)(null); | ||
var timeout = (0, _react.useRef)(null); // Clear the timeout on component unmount. | ||
(0, _react.useEffect)(function () { | ||
return function () { | ||
return clearTimeout(timeout.current); | ||
}; | ||
}, []); | ||
(0, _react.useEffect)(function () { | ||
// Avoid triggering the update loop on the component mount lifecycle. | ||
// Use the absence of the queue reference to indentify this case. | ||
if (!queue.current) { | ||
queue.current = []; | ||
return; | ||
} | ||
var updateValue = function updateValue() { | ||
if (!queue.current.length) { | ||
timeout.current = clearTimeout(timeout.current); | ||
return; | ||
} | ||
setThrottledValue(queue.current.shift()); | ||
timeout.current = setTimeout(updateValue, delay); | ||
}; // Add every value change to the update | ||
queue.current.push(value); // If there is currently a change queued to occur, we do nothing. | ||
// Otherwise, trigger the update loop by setting the timeout. | ||
timeout.current = timeout.current || setTimeout(updateValue, 0); | ||
}, [value]); | ||
return throttledValue; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLXRocm90dGxlL2luZGV4LmpzIl0sIm5hbWVzIjpbInVzZVRocm90dGxlIiwidmFsdWUiLCJkZWxheSIsInRocm90dGxlZFZhbHVlIiwic2V0VGhyb3R0bGVkVmFsdWUiLCJxdWV1ZSIsInRpbWVvdXQiLCJjbGVhclRpbWVvdXQiLCJjdXJyZW50IiwidXBkYXRlVmFsdWUiLCJsZW5ndGgiLCJzaGlmdCIsInNldFRpbWVvdXQiLCJwdXNoIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQUE7Ozs7Ozs7Ozs7QUFFZSxTQUFTQSxXQUFULENBQXFCQyxLQUFyQixFQUE0QkMsS0FBNUIsRUFBbUM7QUFBQSxrQkFDRixxQkFBU0QsS0FBVCxDQURFO0FBQUE7QUFBQSxNQUN2Q0UsY0FEdUM7QUFBQSxNQUN2QkMsaUJBRHVCLGtCQUU5Qzs7O0FBQ0EsTUFBTUMsS0FBSyxHQUFHLG1CQUFPLElBQVAsQ0FBZDtBQUNBLE1BQU1DLE9BQU8sR0FBRyxtQkFBTyxJQUFQLENBQWhCLENBSjhDLENBTTlDOztBQUNBLHdCQUFVO0FBQUEsV0FBTTtBQUFBLGFBQU1DLFlBQVksQ0FBQ0QsT0FBTyxDQUFDRSxPQUFULENBQWxCO0FBQUEsS0FBTjtBQUFBLEdBQVYsRUFBcUQsRUFBckQ7QUFFQSx3QkFBVSxZQUFNO0FBQ1o7QUFDQTtBQUNBLFFBQUksQ0FBQ0gsS0FBSyxDQUFDRyxPQUFYLEVBQW9CO0FBQ2hCSCxNQUFBQSxLQUFLLENBQUNHLE9BQU4sR0FBZ0IsRUFBaEI7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XVlLmN1cnJlbnQucHVzaCh2YWx1ZSlcblxuICAgICAgICAvLyBJZiB0aGVyZSBpcyBjdXJyZW50bHkgYSBjaGFuZ2UgcXVldWVkIHRvIG9jY3VyLCB3ZSBkbyBub3RoaW5nLlxuICAgICAgICAvLyBPdGhlcndpc2UsIHRyaWdnZXIgdGhlIHVwZGF0ZSBsb29wIGJ5IHNldHRpbmcgdGhlIHRpbWVvdXQuXG4gICAgICAgIHRpbWVvdXQuY3VycmVudCA9IHRpbWVvdXQuY3VycmVudCB8fCBzZXRUaW1lb3V0KHVwZGF0ZVZhbHVlLCAwKVxuICAgIH0sIFt2YWx1ZV0pXG5cbiAgcmV0dXJuIHRocm90dGxlZFZhbHVlXG59XG4iXX0= | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=useThrottle;var _react=require("react");function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function useThrottle(value,delay){var _useState=(0,_react.useState)(value),_useState2=_slicedToArray(_useState,2),throttledValue=_useState2[0],setThrottledValue=_useState2[1];// Use queue & timeout to power the update loop. | ||
var queue=(0,_react.useRef)(null);var timeout=(0,_react.useRef)(null);// Clear the timeout on component unmount. | ||
(0,_react.useEffect)(function(){return function(){return clearTimeout(timeout.current)}},[]);(0,_react.useEffect)(function(){// Avoid triggering the update loop on the component mount lifecycle. | ||
// Use the absence of the queue reference to indentify this case. | ||
if(!queue.current){queue.current=[];return}var updateValue=function updateValue(){if(!queue.current.length){timeout.current=clearTimeout(timeout.current);return}setThrottledValue(queue.current.shift());timeout.current=setTimeout(updateValue,delay)};// Add every value change to the update | ||
queue.current.push(value);// If there is currently a change queued to occur, we do nothing. | ||
// Otherwise, trigger the update loop by setting the timeout. | ||
timeout.current=timeout.current||setTimeout(updateValue,0)},[value]);return throttledValue} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXNlLXRocm90dGxlL2luZGV4LmpzIl0sIm5hbWVzIjpbInVzZVRocm90dGxlIiwidmFsdWUiLCJkZWxheSIsInRocm90dGxlZFZhbHVlIiwic2V0VGhyb3R0bGVkVmFsdWUiLCJxdWV1ZSIsInRpbWVvdXQiLCJjbGVhclRpbWVvdXQiLCJjdXJyZW50IiwidXBkYXRlVmFsdWUiLCJsZW5ndGgiLCJzaGlmdCIsInNldFRpbWVvdXQiLCJwdXNoIl0sIm1hcHBpbmdzIjoia0dBQUEsNEIsaW1CQUVlLFFBQVNBLENBQUFBLFdBQVQsQ0FBcUJDLEtBQXJCLENBQTRCQyxLQUE1QixDQUFtQyxlQUNGLG9CQUFTRCxLQUFULENBREUsd0NBQ3ZDRSxjQUR1QyxlQUN2QkMsaUJBRHVCLGVBRTlDO0FBQ0EsR0FBTUMsQ0FBQUEsS0FBSyxDQUFHLGtCQUFPLElBQVAsQ0FBZCxDQUNBLEdBQU1DLENBQUFBLE9BQU8sQ0FBRyxrQkFBTyxJQUFQLENBQWhCLENBRUE7QUFDQSxxQkFBVSxpQkFBTSxrQkFBTUMsQ0FBQUEsWUFBWSxDQUFDRCxPQUFPLENBQUNFLE9BQVQsQ0FBbEIsQ0FBTixDQUFWLENBQXFELEVBQXJELEVBRUEscUJBQVUsVUFBTSxDQUNaO0FBQ0E7QUFDQSxHQUFJLENBQUNILEtBQUssQ0FBQ0csT0FBWCxDQUFvQixDQUNoQkgsS0FBSyxDQUFDRyxPQUFOLENBQW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biAgICAgICAgLy8gSWYgdGhlcmUgaXMgY3VycmVudGx5IGEgY2hhbmdlIHF1ZXVlZCB0byBvY2N1ciwgd2UgZG8gbm90aGluZy5cbiAgICAgICAgLy8gT3RoZXJ3aXNlLCB0cmlnZ2VyIHRoZSB1cGRhdGUgbG9vcCBieSBzZXR0aW5nIHRoZSB0aW1lb3V0LlxuICAgICAgICB0aW1lb3V0LmN1cnJlbnQgPSB0aW1lb3V0LmN1cnJlbnQgfHwgc2V0VGltZW91dCh1cGRhdGVWYWx1ZSwgMClcbiAgICB9LCBbdmFsdWVdKVxuXG4gIHJldHVybiB0aHJvdHRsZWRWYWx1ZVxufVxuIl19 |
@@ -1,65 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getPointerPosition = exports.getTouchPosition = exports.getMousePosition = exports.bulkRemoveEventListener = exports.bulkAddEventListener = exports.noop = void 0; | ||
var noop = function noop() {}; | ||
exports.noop = noop; | ||
var bulkAddEventListener = function bulkAddEventListener(object) { | ||
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var callback = arguments.length > 2 ? arguments[2] : undefined; | ||
if (!object) { | ||
return; | ||
} | ||
events.forEach(function (event) { | ||
object.addEventListener(event, callback); | ||
}); | ||
}; | ||
exports.bulkAddEventListener = bulkAddEventListener; | ||
var bulkRemoveEventListener = function bulkRemoveEventListener(object) { | ||
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var callback = arguments.length > 2 ? arguments[2] : undefined; | ||
if (!object) { | ||
return; | ||
} | ||
events.forEach(function (event) { | ||
object.removeEventListener(event, callback); | ||
}); | ||
}; | ||
exports.bulkRemoveEventListener = bulkRemoveEventListener; | ||
var getMousePosition = function getMousePosition(e) { | ||
return { | ||
x: e.pageX - (window.scrollX || window.pageXOffset), | ||
y: e.pageY - (window.scrollY || window.pageYOffset) | ||
}; | ||
}; | ||
exports.getMousePosition = getMousePosition; | ||
var getTouchPosition = function getTouchPosition(e) { | ||
return { | ||
x: e.touches[0].pageX - (window.scrollX || window.pageXOffset), | ||
y: e.touches[0].pageY - (window.scrollY || window.pageYOffset) | ||
}; | ||
}; | ||
exports.getTouchPosition = getTouchPosition; | ||
var getPointerPosition = function getPointerPosition(e) { | ||
return e.touches ? getTouchPosition(e) : getMousePosition(e); | ||
}; | ||
exports.getPointerPosition = getPointerPosition; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXRpbHMvaW5kZXguanMiXSwibmFtZXMiOlsibm9vcCIsImJ1bGtBZGRFdmVudExpc3RlbmVyIiwib2JqZWN0IiwiZXZlbnRzIiwiY2FsbGJhY2siLCJmb3JFYWNoIiwiZXZlbnQiLCJhZGRFdmVudExpc3RlbmVyIiwiYnVsa1JlbW92ZUV2ZW50TGlzdGVuZXIiLCJyZW1vdmVFdmVudExpc3RlbmVyIiwiZ2V0TW91c2VQb3NpdGlvbiIsImUiLCJ4IiwicGFnZVgiLCJ3aW5kb3ciLCJzY3JvbGxYIiwicGFnZVhPZmZzZXQiLCJ5IiwicGFnZVkiLCJzY3JvbGxZIiwicGFnZVlPZmZzZXQiLCJnZXRUb3VjaFBvc2l0aW9uIiwidG91Y2hlcyIsImdldFBvaW50ZXJQb3NpdGlvbiJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQUFPLElBQU1BLElBQUksR0FBRyxTQUFQQSxJQUFPLEdBQU0sQ0FBRSxDQUFyQjs7OztBQUVBLElBQU1DLG9CQUFvQixHQUFHLFNBQXZCQSxvQkFBdUIsQ0FBQ0MsTUFBRCxFQUFtQztBQUFBLE1BQTFCQyxNQUEwQix1RUFBakIsRUFBaUI7QUFBQSxNQUFiQyxRQUFhOztBQUNuRSxNQUFJLENBQUNGLE1BQUwsRUFBYTtBQUNUO0FBQ0g7O0FBRURDLEVBQUFBLE1BQU0sQ0FBQ0UsT0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Nb3VzZVBvc2l0aW9uID0gKGUpID0+IHtcbiAgICByZXR1cm4ge1xuICAgICAgICB4OiBlLnBhZ2VYIC0gKHdpbmRvdy5zY3JvbGxYIHx8IHdpbmRvdy5wYWdlWE9mZnNldCksXG4gICAgICAgIHk6IGUucGFnZVkgLSAod2luZG93LnNjcm9sbFkgfHwgd2luZG93LnBhZ2VZT2Zmc2V0KVxuICAgIH1cbn1cblxuZXhwb3J0IGNvbnN0IGdldFRvdWNoUG9zaXRpb24gPSAoZSkgPT4ge1xuICAgIHJldHVybiB7XG4gICAgICAgIHg6IGUudG91Y2hlc1swXS5wYWdlWCAtICh3aW5kb3cuc2Nyb2xsWCB8fCB3aW5kb3cucGFnZVhPZmZzZXQpLFxuICAgICAgICB5OiBlLnRvdWNoZXNbMF0ucGFnZVkgLSAod2luZG93LnNjcm9sbFkgfHwgd2luZG93LnBhZ2VZT2Zmc2V0KVxuICAgIH1cbn1cblxuZXhwb3J0IGNvbnN0IGdldFBvaW50ZXJQb3NpdGlvbiA9IChlKSA9PiB7XG4gICAgcmV0dXJuIGUudG91Y2hlc1xuICAgICAgICA/IGdldFRvdWNoUG9zaXRpb24oZSlcbiAgICAgICAgOiBnZXRNb3VzZVBvc2l0aW9uKGUpXG59XG4iXX0= | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getPointerPosition=exports.getTouchPosition=exports.getMousePosition=exports.bulkRemoveEventListener=exports.bulkAddEventListener=exports.noop=void 0;var noop=function noop(){};exports.noop=noop;var bulkAddEventListener=function bulkAddEventListener(object){var events=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var callback=arguments.length>2?arguments[2]:undefined;if(!object){return}events.forEach(function(event){object.addEventListener(event,callback)})};exports.bulkAddEventListener=bulkAddEventListener;var bulkRemoveEventListener=function bulkRemoveEventListener(object){var events=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var callback=arguments.length>2?arguments[2]:undefined;if(!object){return}events.forEach(function(event){object.removeEventListener(event,callback)})};exports.bulkRemoveEventListener=bulkRemoveEventListener;var getMousePosition=function getMousePosition(e){return{x:e.pageX-(window.scrollX||window.pageXOffset),y:e.pageY-(window.scrollY||window.pageYOffset)}};exports.getMousePosition=getMousePosition;var getTouchPosition=function getTouchPosition(e){return{x:e.touches[0].pageX-(window.scrollX||window.pageXOffset),y:e.touches[0].pageY-(window.scrollY||window.pageYOffset)}};exports.getTouchPosition=getTouchPosition;var getPointerPosition=function getPointerPosition(e){return e.touches?getTouchPosition(e):getMousePosition(e)};exports.getPointerPosition=getPointerPosition; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3JlY2lwZXMvdXRpbHMvaW5kZXguanMiXSwibmFtZXMiOlsibm9vcCIsImJ1bGtBZGRFdmVudExpc3RlbmVyIiwib2JqZWN0IiwiZXZlbnRzIiwiY2FsbGJhY2siLCJmb3JFYWNoIiwiZXZlbnQiLCJhZGRFdmVudExpc3RlbmVyIiwiYnVsa1JlbW92ZUV2ZW50TGlzdGVuZXIiLCJyZW1vdmVFdmVudExpc3RlbmVyIiwiZ2V0TW91c2VQb3NpdGlvbiIsImUiLCJ4IiwicGFnZVgiLCJ3aW5kb3ciLCJzY3JvbGxYIiwicGFnZVhPZmZzZXQiLCJ5IiwicGFnZVkiLCJzY3JvbGxZIiwicGFnZVlPZmZzZXQiLCJnZXRUb3VjaFBvc2l0aW9uIiwidG91Y2hlcyIsImdldFBvaW50ZXJQb3NpdGlvbiJdLCJtYXBwaW5ncyI6Im9PQUFPLEdBQU1BLENBQUFBLElBQUksQ0FBRyxRQUFQQSxDQUFBQSxJQUFPLEVBQU0sQ0FBRSxDQUFyQixDLGtCQUVBLEdBQU1DLENBQUFBLG9CQUFvQixDQUFHLFFBQXZCQSxDQUFBQSxvQkFBdUIsQ0FBQ0MsTUFBRCxDQUFtQyxJQUExQkMsQ0FBQUEsTUFBMEIsMkRBQWpCLEVBQWlCLElBQWJDLENB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iB7XG4gICAgICAgIG9iamVjdC5yZW1vdmVFdmVudExpc3RlbmVyKGV2ZW50LCBjYWxsYmFjaylcbiAgICB9KVxufVxuXG5leHBvcnQgY29uc3QgZ2V0TW91c2VQb3NpdGlvbiA9IChlKSA9PiB7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgeDogZS5wYWdlWCAtICh3aW5kb3cuc2Nyb2xsWCB8fCB3aW5kb3cucGFnZVhPZmZzZXQpLFxuICAgICAgICB5OiBlLnBhZ2VZIC0gKHdpbmRvdy5zY3JvbGxZIHx8IHdpbmRvdy5wYWdlWU9mZnNldClcbiAgICB9XG59XG5cbmV4cG9ydCBjb25zdCBnZXRUb3VjaFBvc2l0aW9uID0gKGUpID0+IHtcbiAgICByZXR1cm4ge1xuICAgICAgICB4OiBlLnRvdWNoZXNbMF0ucGFnZVggLSAod2luZG93LnNjcm9sbFggfHwgd2luZG93LnBhZ2VYT2Zmc2V0KSxcbiAgICAgICAgeTogZS50b3VjaGVzWzBdLnBhZ2VZIC0gKHdpbmRvdy5zY3JvbGxZIHx8IHdpbmRvdy5wYWdlWU9mZnNldClcbiAgICB9XG59XG5cbmV4cG9ydCBjb25zdCBnZXRQb2ludGVyUG9zaXRpb24gPSAoZSkgPT4ge1xuICAgIHJldHVybiBlLnRvdWNoZXNcbiAgICAgICAgPyBnZXRUb3VjaFBvc2l0aW9uKGUpXG4gICAgICAgIDogZ2V0TW91c2VQb3NpdGlvbihlKVxufVxuIl19 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39857
76
4
1