New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scroll-sensor

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-sensor - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

build/webpack.config.base.js

@@ -16,4 +16,8 @@ const path = require('path');

{
test: /\.js$/,
use: [{ loader: 'babel-loader' }],
},
{
test: /\.ts$/,
use: [{ loader: 'babel-loader' }, { loader: 'eslint-loader' }],
use: [{ loader: 'ts-loader' }, { loader: 'eslint-loader' }],
},

@@ -20,0 +24,0 @@ ],

850

dist/scroll-sensor.common.js

@@ -96,158 +96,319 @@ module.exports =

/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: external "events"
var external_events_ = __webpack_require__(0);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var events_1 = __webpack_require__(0);
var model_1 = __webpack_require__(2);
var util_1 = __webpack_require__(3);
/**
* Scroll sensor main class
* @event scroll Emit when scroll.
*/
var ScrollSensor = /** @class */ (function (_super) {
__extends(ScrollSensor, _super);
/**
* @param {HTMLElement} element The dom element to create the ScrollSensor instance.
* @param {OptionsInterface} options Options.
* @param {number} initialScrollTop
* @param {number} initialScrollLeft
*/
function ScrollSensor(_a) {
var element = _a.element, _b = _a.options, options = _b === void 0 ? {} : _b, _c = _a.initialScrollTop, initialScrollTop = _c === void 0 ? 0 : _c, _d = _a.initialScrollLeft, initialScrollLeft = _d === void 0 ? 0 : _d;
var _this = _super.call(this) || this;
_this.mouseIsScrolling = false;
_this.mouseScrollEndInertiaUtil = new util_1.EndInertiaUtil();
_this.touchEndInertiaUtil = new util_1.EndInertiaUtil();
_this.handleMousewheel = function (event) {
if (!_this.options.mouseWheelIsEnable) {
return;
}
_this.move(event.deltaX * _this.options.mouseWheelXSpeed, event.deltaY * _this.options.mouseWheelYSpeed);
};
_this.handleMouseDown = function (event) {
if (!_this.options.mouseMoveIsEnable) {
return;
}
_this.mouseXLastPosition = event.clientX;
_this.mouseYLastPosition = event.clientY;
_this.mouseIsScrolling = true;
_this.mouseScrollEndInertiaUtil.stop();
};
_this.handleMouseMove = function (event) {
if (_this.mouseIsScrolling) {
var xDistance = _this.mouseXLastPosition - event.clientX;
var yDistance = _this.mouseYLastPosition - event.clientY;
_this.move(xDistance * _this.options.mouseMoveXSpeed, yDistance * _this.options.mouseMoveYSpeed);
_this.mouseXLastPosition = event.clientX;
_this.mouseYLastPosition = event.clientY;
_this.mouseScrollEndInertiaUtil.push(_this.scrollLeft, _this.scrollTop);
}
};
_this.handleMouseUp = function () {
_this.mouseIsScrolling = false;
_this.mouseScrollEndInertiaUtil.end();
};
_this.handleTouchStart = function (event) {
if (!_this.options.touchIsEnable) {
return;
}
_this.touchXLastPosition = Math.round(event.touches[0].clientX);
_this.touchYLastPosition = Math.round(event.touches[0].clientY);
_this.touchEndInertiaUtil.stop();
};
_this.handleTouchMove = function (event) {
if (!_this.options.touchIsEnable) {
return;
}
var clientX = Math.round(event.touches[0].clientX);
var clientY = Math.round(event.touches[0].clientY);
var xDistance = _this.touchXLastPosition - clientX;
var yDistance = _this.touchYLastPosition - clientY;
_this.move(xDistance, yDistance);
_this.touchXLastPosition = clientX;
_this.touchYLastPosition = clientY;
_this.touchEndInertiaUtil.push(_this.scrollLeft, _this.scrollTop);
};
_this.handleTouchEnd = function () {
_this.touchEndInertiaUtil.end();
};
_this.handleInertiaMove = function (event) {
_this.move(event.xDistance, event.yDistance);
};
if (!(element instanceof HTMLElement)) {
throw new Error('"element" param is must an instance of HTMLElement');
}
_this.setOptions(options);
_this.element = element;
_this.scrollTop = initialScrollTop;
_this.scrollLeft = initialScrollLeft;
_this.element.addEventListener('mousewheel', _this.handleMousewheel);
_this.element.addEventListener('mousedown', _this.handleMouseDown);
_this.element.addEventListener('mousemove', _this.handleMouseMove);
_this.element.addEventListener('mouseup', _this.handleMouseUp);
_this.element.addEventListener('touchstart', _this.handleTouchStart);
_this.element.addEventListener('touchmove', _this.handleTouchMove);
_this.element.addEventListener('touchend', _this.handleTouchEnd);
_this.mouseScrollEndInertiaUtil.on('inertiaMove', _this.handleInertiaMove);
_this.touchEndInertiaUtil.on('inertiaMove', _this.handleInertiaMove);
return _this;
}
ScrollSensor.prototype.setOptions = function (options) {
if (options === void 0) { options = {}; }
this.options = new model_1.Options(options);
this.mouseScrollEndInertiaUtil.setXDecelerationPerSecond(this.options.mouseMoveInertiaXDeceleration);
this.mouseScrollEndInertiaUtil.setYDecelerationPerSecond(this.options.mouseMoveInertiaYDeceleration);
this.mouseScrollEndInertiaUtil.setXMaxSpeed(this.options.mouseMoveInertiaXMaxSpeed);
this.mouseScrollEndInertiaUtil.setYMaxSpeed(this.options.mouseMoveInertiaYMaxSpeed);
this.touchEndInertiaUtil.setXDecelerationPerSecond(this.options.touchInertiaXDeceleration);
this.touchEndInertiaUtil.setYDecelerationPerSecond(this.options.touchInertiaYDeceleration);
this.touchEndInertiaUtil.setXMaxSpeed(this.options.touchInertiaXMaxSpeed);
this.touchEndInertiaUtil.setYMaxSpeed(this.options.touchInertiaYMaxSpeed);
};
Object.defineProperty(ScrollSensor.prototype, "scrollTop", {
get: function () {
return this._scrollTop;
},
set: function (scrollTop) {
if (scrollTop < this.options.minScrollTop) {
this._scrollTop = this.options.minScrollTop;
}
else if (scrollTop > this.options.maxScrollTop) {
this._scrollTop = this.options.maxScrollTop;
}
else {
this._scrollTop = scrollTop;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ScrollSensor.prototype, "scrollLeft", {
get: function () {
return this._scrollLeft;
},
set: function (scrollLeft) {
if (scrollLeft < this.options.minScrollLeft) {
this._scrollLeft = this.options.minScrollLeft;
}
else if (scrollLeft > this.options.maxScrollLeft) {
this._scrollLeft = this.options.maxScrollLeft;
}
else {
this._scrollLeft = scrollLeft;
}
},
enumerable: true,
configurable: true
});
/**
* Release the resources.
*/
ScrollSensor.prototype.destroy = function () {
this.mouseScrollEndInertiaUtil.removeAllListeners();
this.touchEndInertiaUtil.removeAllListeners();
this.element.removeEventListener('mousewheel', this.handleMousewheel);
this.element.removeEventListener('mousedown', this.handleMouseDown);
this.element.removeEventListener('mousemove', this.handleMouseMove);
this.element.removeEventListener('mouseup', this.handleMouseUp);
this.element.removeEventListener('touchstart', this.handleTouchStart);
this.element.removeEventListener('touchmove', this.handleTouchMove);
this.element.removeEventListener('touchend', this.handleTouchEnd);
};
ScrollSensor.prototype.move = function (xDistance, yDistance) {
this.scrollLeft = this.scrollLeft + xDistance;
this.scrollTop = this.scrollTop + yDistance;
var eventObject = new model_1.ScrollEventObject(this.scrollTop, this.scrollLeft, yDistance, xDistance);
this.emit('scroll', eventObject);
};
return ScrollSensor;
}(events_1.EventEmitter));
exports.ScrollSensor = ScrollSensor;
// CONCATENATED MODULE: ./src/model.ts
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; }
class Options {
constructor(options = {}) {
_defineProperty(this, "mouseWheelIsEnable", void 0);
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
_defineProperty(this, "mouseWheelXSpeed", void 0);
"use strict";
_defineProperty(this, "mouseWheelYSpeed", void 0);
_defineProperty(this, "mouseMoveIsEnable", void 0);
_defineProperty(this, "mouseMoveXSpeed", void 0);
_defineProperty(this, "mouseMoveYSpeed", void 0);
_defineProperty(this, "mouseMoveInertiaXDeceleration", void 0);
_defineProperty(this, "mouseMoveInertiaYDeceleration", void 0);
_defineProperty(this, "mouseMoveInertiaXMaxSpeed", void 0);
_defineProperty(this, "mouseMoveInertiaYMaxSpeed", void 0);
_defineProperty(this, "touchIsEnable", void 0);
_defineProperty(this, "touchXSpeed", void 0);
_defineProperty(this, "touchYSpeed", void 0);
_defineProperty(this, "touchInertiaXDeceleration", void 0);
_defineProperty(this, "touchInertiaYDeceleration", void 0);
_defineProperty(this, "touchInertiaXMaxSpeed", void 0);
_defineProperty(this, "touchInertiaYMaxSpeed", void 0);
_defineProperty(this, "minScrollTop", void 0);
_defineProperty(this, "minScrollLeft", void 0);
_defineProperty(this, "maxScrollTop", void 0);
_defineProperty(this, "maxScrollLeft", void 0);
this.mouseWheelIsEnable = this.dealParam(options.mouseWheelIsEnable, true);
this.mouseWheelXSpeed = this.dealParam(options.mouseWheelXSpeed, 1);
this.mouseWheelYSpeed = this.dealParam(options.mouseWheelYSpeed, 1);
this.mouseMoveIsEnable = this.dealParam(options.mouseMoveIsEnable, true);
this.mouseMoveXSpeed = this.dealParam(options.mouseMoveXSpeed, 1);
this.mouseMoveYSpeed = this.dealParam(options.mouseMoveYSpeed, 1);
this.mouseMoveInertiaXDeceleration = this.dealParam(options.mouseMoveInertiaXDeceleration, Infinity);
this.mouseMoveInertiaYDeceleration = this.dealParam(options.mouseMoveInertiaYDeceleration, Infinity);
this.mouseMoveInertiaXMaxSpeed = this.dealParam(options.mouseMoveInertiaXMaxSpeed, this.mouseMoveInertiaXDeceleration);
this.mouseMoveInertiaYMaxSpeed = this.dealParam(options.mouseMoveInertiaYMaxSpeed, this.mouseMoveInertiaYDeceleration);
this.touchIsEnable = this.dealParam(options.touchIsEnable, true);
this.touchXSpeed = this.dealParam(options.touchXSpeed, 1);
this.touchYSpeed = this.dealParam(options.touchYSpeed, 1);
this.touchInertiaXDeceleration = this.dealParam(options.touchInertiaXDeceleration, Infinity);
this.touchInertiaYDeceleration = this.dealParam(options.touchInertiaYDeceleration, Infinity);
this.touchInertiaXMaxSpeed = this.dealParam(options.touchInertiaXMaxSpeed, this.touchInertiaXDeceleration);
this.touchInertiaYMaxSpeed = this.dealParam(options.touchInertiaYMaxSpeed, this.touchInertiaYDeceleration);
this.minScrollTop = this.dealParam(options.minScrollTop, 0);
this.minScrollLeft = this.dealParam(options.minScrollLeft, 0);
this.maxScrollTop = this.dealParam(options.maxScrollTop, Infinity);
this.maxScrollLeft = this.dealParam(options.maxScrollLeft, 0);
}
dealParam(param, defaultValue) {
if (param === undefined || param === null) {
return defaultValue;
} else {
return param;
Object.defineProperty(exports, "__esModule", { value: true });
var Options = /** @class */ (function () {
function Options(options) {
if (options === void 0) { options = {}; }
this.mouseWheelIsEnable = this.dealParam(options.mouseWheelIsEnable, true);
this.mouseWheelXSpeed = this.dealParam(options.mouseWheelXSpeed, 1);
this.mouseWheelYSpeed = this.dealParam(options.mouseWheelYSpeed, 1);
this.mouseMoveIsEnable = this.dealParam(options.mouseMoveIsEnable, true);
this.mouseMoveXSpeed = this.dealParam(options.mouseMoveXSpeed, 1);
this.mouseMoveYSpeed = this.dealParam(options.mouseMoveYSpeed, 1);
this.mouseMoveInertiaXDeceleration = this.dealParam(options.mouseMoveInertiaXDeceleration, Infinity);
this.mouseMoveInertiaYDeceleration = this.dealParam(options.mouseMoveInertiaYDeceleration, Infinity);
this.mouseMoveInertiaXMaxSpeed = this.dealParam(options.mouseMoveInertiaXMaxSpeed, this.mouseMoveInertiaXDeceleration);
this.mouseMoveInertiaYMaxSpeed = this.dealParam(options.mouseMoveInertiaYMaxSpeed, this.mouseMoveInertiaYDeceleration);
this.touchIsEnable = this.dealParam(options.touchIsEnable, true);
this.touchXSpeed = this.dealParam(options.touchXSpeed, 1);
this.touchYSpeed = this.dealParam(options.touchYSpeed, 1);
this.touchInertiaXDeceleration = this.dealParam(options.touchInertiaXDeceleration, Infinity);
this.touchInertiaYDeceleration = this.dealParam(options.touchInertiaYDeceleration, Infinity);
this.touchInertiaXMaxSpeed = this.dealParam(options.touchInertiaXMaxSpeed, this.touchInertiaXDeceleration);
this.touchInertiaYMaxSpeed = this.dealParam(options.touchInertiaYMaxSpeed, this.touchInertiaYDeceleration);
this.minScrollTop = this.dealParam(options.minScrollTop, 0);
this.minScrollLeft = this.dealParam(options.minScrollLeft, 0);
this.maxScrollTop = this.dealParam(options.maxScrollTop, Infinity);
this.maxScrollLeft = this.dealParam(options.maxScrollLeft, 0);
}
}
Options.prototype.dealParam = function (param, defaultValue) {
if (param === undefined || param === null) {
return defaultValue;
}
else {
return param;
}
};
return Options;
}());
exports.Options = Options;
var ScrollEventObject = /** @class */ (function () {
function ScrollEventObject(
// current total distance to the top and left
scrollTop, scrollLeft,
// latest scroll distance on the x-axis and y-axis
scrollY, scrollX) {
this.scrollTop = scrollTop;
this.scrollLeft = scrollLeft;
this.scrollY = scrollY;
this.scrollX = scrollX;
}
return ScrollEventObject;
}());
exports.ScrollEventObject = ScrollEventObject;
}
class ScrollEventObject {
constructor(scrollTop, scrollLeft, scrollY, scrollX) {
this.scrollTop = scrollTop;
this.scrollLeft = scrollLeft;
this.scrollY = scrollY;
this.scrollX = scrollX;
}
}
// CONCATENATED MODULE: ./src/util.ts
function util_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; }
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var events_1 = __webpack_require__(0);
/**
* Get positive and negative sign of a number.
*/
function getSign(num) {
if (num > 0) {
return 1;
} else if (num < 0) {
return -1;
} else if (num === 0) {
return 0;
} else {
return NaN;
}
}
class PositionStore {
constructor(endTimeRange) {
this.endTimeRange = endTimeRange;
util_defineProperty(this, "positions", []);
}
filterPositions() {
const now = new Date();
this.positions = this.positions.filter(item => {
return now.getTime() - item[0].getTime() <= this.endTimeRange;
});
}
push(position) {
if (this.positions.length && this.positions[this.positions.length - 1][1] * position < 0) {
this.clear();
if (num > 0) {
return 1;
}
this.positions.push([new Date(), position]);
this.filterPositions();
}
getEndSpeed() {
this.filterPositions();
if (this.positions.length === 0 || this.positions.length === 1) {
return 0;
else if (num < 0) {
return -1;
}
const start = this.positions[0];
const end = this.positions[this.positions.length - 1];
return (end[1] - start[1]) / ((end[0].getTime() - start[0].getTime()) / 1000);
}
clear() {
this.positions = [];
}
else if (num === 0) {
return 0;
}
else {
return NaN;
}
}
exports.getSign = getSign;
var PositionStore = /** @class */ (function () {
function PositionStore(endTimeRange) {
this.endTimeRange = endTimeRange;
this.positions = [];
}
PositionStore.prototype.filterPositions = function () {
var _this = this;
var now = new Date();
this.positions = this.positions.filter(function (item) {
return now.getTime() - item[0].getTime() <= _this.endTimeRange;
});
};
PositionStore.prototype.push = function (position) {
if (this.positions.length && (this.positions[this.positions.length - 1][1] * position < 0)) {
this.clear();
}
this.positions.push([new Date(), position]);
this.filterPositions();
};
PositionStore.prototype.getEndSpeed = function () {
this.filterPositions();
if (this.positions.length === 0 || this.positions.length === 1) {
return 0;
}
var start = this.positions[0];
var end = this.positions[this.positions.length - 1];
return (end[1] - start[1]) / ((end[0].getTime() - start[0].getTime()) / 1000);
};
PositionStore.prototype.clear = function () {
this.positions = [];
};
return PositionStore;
}());
/**

@@ -258,323 +419,108 @@ * A util to deal scroll end inertia.

*/
class util_EndInertiaUtil extends external_events_["EventEmitter"] {
constructor(endTimeRange = 200, xDecelerationPerSecond = Infinity, yDecelerationPerSecond = Infinity, xMaxSpeed = Infinity, yMaxSpeed = Infinity) {
super();
this.xDecelerationPerSecond = xDecelerationPerSecond;
this.yDecelerationPerSecond = yDecelerationPerSecond;
this.xMaxSpeed = xMaxSpeed;
this.yMaxSpeed = yMaxSpeed;
util_defineProperty(this, "xPositionStore", void 0);
util_defineProperty(this, "yPositionStore", void 0);
util_defineProperty(this, "timer", void 0);
this.xPositionStore = new PositionStore(endTimeRange);
this.yPositionStore = new PositionStore(endTimeRange);
}
setEndTimeRange(endTimeRange) {
this.xPositionStore.endTimeRange = endTimeRange;
this.yPositionStore.endTimeRange = endTimeRange;
}
setXDecelerationPerSecond(xDecelerationPerSecond) {
this.xDecelerationPerSecond = xDecelerationPerSecond;
}
setYDecelerationPerSecond(yDecelerationPerSecond) {
this.yDecelerationPerSecond = yDecelerationPerSecond;
}
setXMaxSpeed(xMaxSpeed) {
this.xMaxSpeed = xMaxSpeed;
}
setYMaxSpeed(yMaxSpeed) {
this.yMaxSpeed = yMaxSpeed;
}
/**
* Push a move position.It will be used to calculate the end speed.
*/
push(positionX, positionY) {
this.xPositionStore.push(positionX);
this.yPositionStore.push(positionY);
}
/**
* End a series of position push and start to calculate inertia move distance and emit "inertiaMove" event.
*/
end() {
if (this.timer) {
window.clearInterval(this.timer);
var EndInertiaUtil = /** @class */ (function (_super) {
__extends(EndInertiaUtil, _super);
function EndInertiaUtil(endTimeRange, xDecelerationPerSecond, yDecelerationPerSecond, xMaxSpeed, yMaxSpeed) {
if (endTimeRange === void 0) { endTimeRange = 200; }
if (xDecelerationPerSecond === void 0) { xDecelerationPerSecond = Infinity; }
if (yDecelerationPerSecond === void 0) { yDecelerationPerSecond = Infinity; }
if (xMaxSpeed === void 0) { xMaxSpeed = Infinity; }
if (yMaxSpeed === void 0) { yMaxSpeed = Infinity; }
var _this = _super.call(this) || this;
_this.xDecelerationPerSecond = xDecelerationPerSecond;
_this.yDecelerationPerSecond = yDecelerationPerSecond;
_this.xMaxSpeed = xMaxSpeed;
_this.yMaxSpeed = yMaxSpeed;
_this.xPositionStore = new PositionStore(endTimeRange);
_this.yPositionStore = new PositionStore(endTimeRange);
return _this;
}
const originalXSpeed = this.dealOriginalSpeed(this.xPositionStore.getEndSpeed(), this.xMaxSpeed);
const originalYSpeed = this.dealOriginalSpeed(this.yPositionStore.getEndSpeed(), this.yMaxSpeed);
const xDecelerationPerSecond = getSign(originalXSpeed) === 0 ? 0 : getSign(originalXSpeed) * this.xDecelerationPerSecond;
const yDecelerationPerSecond = getSign(originalYSpeed) === 0 ? 0 : getSign(originalYSpeed) * this.yDecelerationPerSecond;
let xSpeed = originalXSpeed;
let ySpeed = originalYSpeed;
let time = Date.now();
this.timer = setInterval(() => {
const pastSeconds = (Date.now() - time) / 1000;
if (pastSeconds === 0) {
return;
}
xSpeed = xSpeed - pastSeconds * xDecelerationPerSecond;
ySpeed = ySpeed - pastSeconds * yDecelerationPerSecond;
time = Date.now();
if (xSpeed * originalXSpeed > 0 || ySpeed * originalYSpeed > 0) {
if (isNaN(xSpeed * originalXSpeed) || xSpeed * originalXSpeed < 0) {
xSpeed = 0;
EndInertiaUtil.prototype.setEndTimeRange = function (endTimeRange) {
this.xPositionStore.endTimeRange = endTimeRange;
this.yPositionStore.endTimeRange = endTimeRange;
};
EndInertiaUtil.prototype.setXDecelerationPerSecond = function (xDecelerationPerSecond) {
this.xDecelerationPerSecond = xDecelerationPerSecond;
};
EndInertiaUtil.prototype.setYDecelerationPerSecond = function (yDecelerationPerSecond) {
this.yDecelerationPerSecond = yDecelerationPerSecond;
};
EndInertiaUtil.prototype.setXMaxSpeed = function (xMaxSpeed) {
this.xMaxSpeed = xMaxSpeed;
};
EndInertiaUtil.prototype.setYMaxSpeed = function (yMaxSpeed) {
this.yMaxSpeed = yMaxSpeed;
};
/**
* Push a move position.It will be used to calculate the end speed.
*/
EndInertiaUtil.prototype.push = function (positionX, positionY) {
this.xPositionStore.push(positionX);
this.yPositionStore.push(positionY);
};
/**
* End a series of position push and start to calculate inertia move distance and emit "inertiaMove" event.
*/
EndInertiaUtil.prototype.end = function () {
var _this = this;
if (this.timer) {
window.clearInterval(this.timer);
}
if (isNaN(xSpeed * originalYSpeed) || ySpeed * originalYSpeed < 0) {
ySpeed = 0;
var originalXSpeed = this.dealOriginalSpeed(this.xPositionStore.getEndSpeed(), this.xMaxSpeed);
var originalYSpeed = this.dealOriginalSpeed(this.yPositionStore.getEndSpeed(), this.yMaxSpeed);
var xDecelerationPerSecond = getSign(originalXSpeed) === 0 ? 0 : getSign(originalXSpeed) * this.xDecelerationPerSecond;
var yDecelerationPerSecond = getSign(originalYSpeed) === 0 ? 0 : getSign(originalYSpeed) * this.yDecelerationPerSecond;
var xSpeed = originalXSpeed;
var ySpeed = originalYSpeed;
var time = Date.now();
this.timer = setInterval(function () {
var pastSeconds = (Date.now() - time) / 1000;
if (pastSeconds === 0) {
return;
}
xSpeed = xSpeed - pastSeconds * xDecelerationPerSecond;
ySpeed = ySpeed - pastSeconds * yDecelerationPerSecond;
time = Date.now();
if (xSpeed * originalXSpeed > 0 || ySpeed * originalYSpeed > 0) {
if (isNaN(xSpeed * originalXSpeed) || xSpeed * originalXSpeed < 0) {
xSpeed = 0;
}
if (isNaN(xSpeed * originalYSpeed) || ySpeed * originalYSpeed < 0) {
ySpeed = 0;
}
_this.emit('inertiaMove', {
xSpeed: xSpeed,
ySpeed: ySpeed,
xDistance: xSpeed * pastSeconds,
yDistance: ySpeed * pastSeconds,
});
}
else {
_this.stop();
}
});
};
/**
* Stop the inertia move.
* It also stop to emit the "inertiaMove" event.
*/
EndInertiaUtil.prototype.stop = function () {
this.xPositionStore.clear();
this.yPositionStore.clear();
window.clearInterval(this.timer);
this.timer = null;
};
EndInertiaUtil.prototype.dealOriginalSpeed = function (speed, maxSpeed) {
if (Math.abs(speed) > maxSpeed) {
return getSign(speed) * maxSpeed;
}
else {
return speed;
}
};
return EndInertiaUtil;
}(events_1.EventEmitter));
exports.EndInertiaUtil = EndInertiaUtil;
this.emit('inertiaMove', {
xSpeed,
ySpeed,
xDistance: xSpeed * pastSeconds,
yDistance: ySpeed * pastSeconds
});
} else {
this.stop();
}
});
}
/**
* Stop the inertia move.
* It also stop to emit the "inertiaMove" event.
*/
stop() {
this.xPositionStore.clear();
this.yPositionStore.clear();
window.clearInterval(this.timer);
this.timer = null;
}
dealOriginalSpeed(speed, maxSpeed) {
if (Math.abs(speed) > maxSpeed) {
return getSign(speed) * maxSpeed;
} else {
return speed;
}
}
}
// CONCATENATED MODULE: ./src/scroll-sensor.ts
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollSensor", function() { return scroll_sensor_ScrollSensor; });
function scroll_sensor_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; }
/**
* Scroll sensor main class
* @event scroll Emit when scroll.
*/
class scroll_sensor_ScrollSensor extends external_events_["EventEmitter"] {
/**
* @param {HTMLElement} element The dom element to create the ScrollSensor instance.
* @param {OptionsInterface} options Options.
* @param {number} initialScrollTop
* @param {number} initialScrollLeft
*/
constructor({
element,
options = {},
initialScrollTop = 0,
initialScrollLeft = 0
}) {
super();
scroll_sensor_defineProperty(this, "element", void 0);
scroll_sensor_defineProperty(this, "options", void 0);
scroll_sensor_defineProperty(this, "_scrollTop", void 0);
scroll_sensor_defineProperty(this, "_scrollLeft", void 0);
scroll_sensor_defineProperty(this, "mouseIsScrolling", false);
scroll_sensor_defineProperty(this, "mouseXLastPosition", void 0);
scroll_sensor_defineProperty(this, "mouseYLastPosition", void 0);
scroll_sensor_defineProperty(this, "mouseScrollEndInertiaUtil", new util_EndInertiaUtil());
scroll_sensor_defineProperty(this, "touchXLastPosition", void 0);
scroll_sensor_defineProperty(this, "touchYLastPosition", void 0);
scroll_sensor_defineProperty(this, "touchEndInertiaUtil", new util_EndInertiaUtil());
scroll_sensor_defineProperty(this, "handleMousewheel", event => {
if (!this.options.mouseWheelIsEnable) {
return;
}
this.move(event.deltaX * this.options.mouseWheelXSpeed, event.deltaY * this.options.mouseWheelYSpeed);
});
scroll_sensor_defineProperty(this, "handleMouseDown", event => {
if (!this.options.mouseMoveIsEnable) {
return;
}
this.mouseXLastPosition = event.clientX;
this.mouseYLastPosition = event.clientY;
this.mouseIsScrolling = true;
this.mouseScrollEndInertiaUtil.stop();
});
scroll_sensor_defineProperty(this, "handleMouseMove", event => {
if (this.mouseIsScrolling) {
const xDistance = this.mouseXLastPosition - event.clientX;
const yDistance = this.mouseYLastPosition - event.clientY;
this.move(xDistance * this.options.mouseMoveXSpeed, yDistance * this.options.mouseMoveYSpeed);
this.mouseXLastPosition = event.clientX;
this.mouseYLastPosition = event.clientY;
this.mouseScrollEndInertiaUtil.push(this.scrollLeft, this.scrollTop);
}
});
scroll_sensor_defineProperty(this, "handleMouseUp", () => {
this.mouseIsScrolling = false;
this.mouseScrollEndInertiaUtil.end();
});
scroll_sensor_defineProperty(this, "handleTouchStart", event => {
if (!this.options.touchIsEnable) {
return;
}
this.touchXLastPosition = Math.round(event.touches[0].clientX);
this.touchYLastPosition = Math.round(event.touches[0].clientY);
this.touchEndInertiaUtil.stop();
});
scroll_sensor_defineProperty(this, "handleTouchMove", event => {
if (!this.options.touchIsEnable) {
return;
}
const clientX = Math.round(event.touches[0].clientX);
const clientY = Math.round(event.touches[0].clientY);
const xDistance = this.touchXLastPosition - clientX;
const yDistance = this.touchYLastPosition - clientY;
this.move(xDistance, yDistance);
this.touchXLastPosition = clientX;
this.touchYLastPosition = clientY;
this.touchEndInertiaUtil.push(this.scrollLeft, this.scrollTop);
});
scroll_sensor_defineProperty(this, "handleTouchEnd", () => {
this.touchEndInertiaUtil.end();
});
scroll_sensor_defineProperty(this, "handleInertiaMove", event => {
this.move(event.xDistance, event.yDistance);
});
if (!(element instanceof HTMLElement)) {
throw new Error('"element" param is must an instance of HTMLElement');
}
this.setOptions(options);
this.element = element;
this.scrollTop = initialScrollTop;
this.scrollLeft = initialScrollLeft;
this.element.addEventListener('mousewheel', this.handleMousewheel);
this.element.addEventListener('mousedown', this.handleMouseDown);
this.element.addEventListener('mousemove', this.handleMouseMove);
this.element.addEventListener('mouseup', this.handleMouseUp);
this.element.addEventListener('touchstart', this.handleTouchStart);
this.element.addEventListener('touchmove', this.handleTouchMove);
this.element.addEventListener('touchend', this.handleTouchEnd);
this.mouseScrollEndInertiaUtil.on('inertiaMove', this.handleInertiaMove);
this.touchEndInertiaUtil.on('inertiaMove', this.handleInertiaMove);
}
setOptions(options = {}) {
this.options = new Options(options);
this.mouseScrollEndInertiaUtil.setXDecelerationPerSecond(this.options.mouseMoveInertiaXDeceleration);
this.mouseScrollEndInertiaUtil.setYDecelerationPerSecond(this.options.mouseMoveInertiaYDeceleration);
this.mouseScrollEndInertiaUtil.setXMaxSpeed(this.options.mouseMoveInertiaXMaxSpeed);
this.mouseScrollEndInertiaUtil.setYMaxSpeed(this.options.mouseMoveInertiaYMaxSpeed);
this.touchEndInertiaUtil.setXDecelerationPerSecond(this.options.touchInertiaXDeceleration);
this.touchEndInertiaUtil.setYDecelerationPerSecond(this.options.touchInertiaYDeceleration);
this.touchEndInertiaUtil.setXMaxSpeed(this.options.touchInertiaXMaxSpeed);
this.touchEndInertiaUtil.setYMaxSpeed(this.options.touchInertiaYMaxSpeed);
}
set scrollTop(scrollTop) {
if (scrollTop < this.options.minScrollTop) {
this._scrollTop = this.options.minScrollTop;
} else if (scrollTop > this.options.maxScrollTop) {
this._scrollTop = this.options.maxScrollTop;
} else {
this._scrollTop = scrollTop;
}
}
get scrollTop() {
return this._scrollTop;
}
set scrollLeft(scrollLeft) {
if (scrollLeft < this.options.minScrollLeft) {
this._scrollLeft = this.options.minScrollLeft;
} else if (scrollLeft > this.options.maxScrollLeft) {
this._scrollLeft = this.options.maxScrollLeft;
} else {
this._scrollLeft = scrollLeft;
}
}
get scrollLeft() {
return this._scrollLeft;
}
/**
* Release the resources.
*/
destroy() {
this.mouseScrollEndInertiaUtil.removeAllListeners();
this.touchEndInertiaUtil.removeAllListeners();
this.element.removeEventListener('mousewheel', this.handleMousewheel);
this.element.removeEventListener('mousedown', this.handleMouseDown);
this.element.removeEventListener('mousemove', this.handleMouseMove);
this.element.removeEventListener('mouseup', this.handleMouseUp);
this.element.removeEventListener('touchstart', this.handleTouchStart);
this.element.removeEventListener('touchmove', this.handleTouchMove);
this.element.removeEventListener('touchend', this.handleTouchEnd);
}
move(xDistance, yDistance) {
this.scrollLeft = this.scrollLeft + xDistance;
this.scrollTop = this.scrollTop + yDistance;
const eventObject = new ScrollEventObject(this.scrollTop, this.scrollLeft, yDistance, xDistance);
this.emit('scroll', eventObject);
}
}
/***/ })
/******/ ]);

@@ -107,3 +107,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

"use strict";
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction $getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return $getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = $getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n ReflectApply(this.listener, this.target, args);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\n\n//# sourceURL=webpack:///./node_modules/events/events.js?");
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\nvar R = typeof Reflect === 'object' ? Reflect : null;\nvar ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n};\nvar ReflectOwnKeys;\n\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys;\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n};\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\n\nmodule.exports = EventEmitter; // Backwards-compat with node 0.10.x\n\nEventEmitter.EventEmitter = EventEmitter;\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\n\nvar defaultMaxListeners = 10;\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function () {\n return defaultMaxListeners;\n },\n set: function (arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function () {\n if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n}; // Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\n\n\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n\n this._maxListeners = n;\n return this;\n};\n\nfunction $getMaxListeners(that) {\n if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return $getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n\n var doError = type === 'error';\n var events = this._events;\n if (events !== undefined) doError = doError && events.error === undefined;else if (!doError) return false; // If there is no 'error' event listener then throw.\n\n if (doError) {\n var er;\n if (args.length > 0) er = args[0];\n\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n } // At least give some kind of context to the user\n\n\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n if (handler === undefined) return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n\n for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = target._events;\n\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type, listener.listener ? listener.listener : listener); // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n\n events = target._events;\n }\n\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] = prepend ? [listener, existing] : [existing, listener]; // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n } // Check for listener leak\n\n\n m = $getMaxListeners(target);\n\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true; // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n\n var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' ' + String(type) + ' listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener = function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n};\n\nfunction onceWrapper() {\n var args = [];\n\n for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);\n\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n ReflectApply(this.listener, this.target, args);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = {\n fired: false,\n wrapFn: undefined,\n target: target,\n type: type,\n listener: listener\n };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n}; // Emits a 'removeListener' event if and only if the listener was removed.\n\n\nEventEmitter.prototype.removeListener = function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = this._events;\n if (events === undefined) return this;\n list = events[type];\n if (list === undefined) return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0) this._events = Object.create(null);else {\n delete events[type];\n if (events.removeListener) this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0) return this;\n if (position === 0) list.shift();else {\n spliceOne(list, position);\n }\n if (list.length === 1) events[type] = list[0];\n if (events.removeListener !== undefined) this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {\n var listeners, events, i;\n events = this._events;\n if (events === undefined) return this; // not listening for removeListener, no need to emit\n\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0) this._events = Object.create(null);else delete events[type];\n }\n\n return this;\n } // emit removeListener for all listeners on all events\n\n\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n};\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n if (events === undefined) return [];\n var evlistener = events[type];\n if (evlistener === undefined) return [];\n if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function (emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\n\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n\n for (var i = 0; i < n; ++i) copy[i] = arr[i];\n\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++) list[index] = list[index + 1];\n\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n\n return ret;\n}\n\n//# sourceURL=webpack:///./node_modules/events/events.js?");

@@ -116,7 +116,7 @@ /***/ }),

\**********************/
/*! exports provided: Options, ScrollEventObject */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Options\", function() { return Options; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ScrollEventObject\", function() { return ScrollEventObject; });\nfunction _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; }\n\nclass Options {\n constructor(options = {}) {\n _defineProperty(this, \"mouseWheelIsEnable\", void 0);\n\n _defineProperty(this, \"mouseWheelXSpeed\", void 0);\n\n _defineProperty(this, \"mouseWheelYSpeed\", void 0);\n\n _defineProperty(this, \"mouseMoveIsEnable\", void 0);\n\n _defineProperty(this, \"mouseMoveXSpeed\", void 0);\n\n _defineProperty(this, \"mouseMoveYSpeed\", void 0);\n\n _defineProperty(this, \"mouseMoveInertiaXDeceleration\", void 0);\n\n _defineProperty(this, \"mouseMoveInertiaYDeceleration\", void 0);\n\n _defineProperty(this, \"mouseMoveInertiaXMaxSpeed\", void 0);\n\n _defineProperty(this, \"mouseMoveInertiaYMaxSpeed\", void 0);\n\n _defineProperty(this, \"touchIsEnable\", void 0);\n\n _defineProperty(this, \"touchXSpeed\", void 0);\n\n _defineProperty(this, \"touchYSpeed\", void 0);\n\n _defineProperty(this, \"touchInertiaXDeceleration\", void 0);\n\n _defineProperty(this, \"touchInertiaYDeceleration\", void 0);\n\n _defineProperty(this, \"touchInertiaXMaxSpeed\", void 0);\n\n _defineProperty(this, \"touchInertiaYMaxSpeed\", void 0);\n\n _defineProperty(this, \"minScrollTop\", void 0);\n\n _defineProperty(this, \"minScrollLeft\", void 0);\n\n _defineProperty(this, \"maxScrollTop\", void 0);\n\n _defineProperty(this, \"maxScrollLeft\", void 0);\n\n this.mouseWheelIsEnable = this.dealParam(options.mouseWheelIsEnable, true);\n this.mouseWheelXSpeed = this.dealParam(options.mouseWheelXSpeed, 1);\n this.mouseWheelYSpeed = this.dealParam(options.mouseWheelYSpeed, 1);\n this.mouseMoveIsEnable = this.dealParam(options.mouseMoveIsEnable, true);\n this.mouseMoveXSpeed = this.dealParam(options.mouseMoveXSpeed, 1);\n this.mouseMoveYSpeed = this.dealParam(options.mouseMoveYSpeed, 1);\n this.mouseMoveInertiaXDeceleration = this.dealParam(options.mouseMoveInertiaXDeceleration, Infinity);\n this.mouseMoveInertiaYDeceleration = this.dealParam(options.mouseMoveInertiaYDeceleration, Infinity);\n this.mouseMoveInertiaXMaxSpeed = this.dealParam(options.mouseMoveInertiaXMaxSpeed, this.mouseMoveInertiaXDeceleration);\n this.mouseMoveInertiaYMaxSpeed = this.dealParam(options.mouseMoveInertiaYMaxSpeed, this.mouseMoveInertiaYDeceleration);\n this.touchIsEnable = this.dealParam(options.touchIsEnable, true);\n this.touchXSpeed = this.dealParam(options.touchXSpeed, 1);\n this.touchYSpeed = this.dealParam(options.touchYSpeed, 1);\n this.touchInertiaXDeceleration = this.dealParam(options.touchInertiaXDeceleration, Infinity);\n this.touchInertiaYDeceleration = this.dealParam(options.touchInertiaYDeceleration, Infinity);\n this.touchInertiaXMaxSpeed = this.dealParam(options.touchInertiaXMaxSpeed, this.touchInertiaXDeceleration);\n this.touchInertiaYMaxSpeed = this.dealParam(options.touchInertiaYMaxSpeed, this.touchInertiaYDeceleration);\n this.minScrollTop = this.dealParam(options.minScrollTop, 0);\n this.minScrollLeft = this.dealParam(options.minScrollLeft, 0);\n this.maxScrollTop = this.dealParam(options.maxScrollTop, Infinity);\n this.maxScrollLeft = this.dealParam(options.maxScrollLeft, 0);\n }\n\n dealParam(param, defaultValue) {\n if (param === undefined || param === null) {\n return defaultValue;\n } else {\n return param;\n }\n }\n\n}\nclass ScrollEventObject {\n constructor(scrollTop, scrollLeft, scrollY, scrollX) {\n this.scrollTop = scrollTop;\n this.scrollLeft = scrollLeft;\n this.scrollY = scrollY;\n this.scrollX = scrollX;\n }\n\n}\n\n//# sourceURL=webpack:///./src/model.ts?");
eval("\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Options = /** @class */ (function () {\r\n function Options(options) {\r\n if (options === void 0) { options = {}; }\r\n this.mouseWheelIsEnable = this.dealParam(options.mouseWheelIsEnable, true);\r\n this.mouseWheelXSpeed = this.dealParam(options.mouseWheelXSpeed, 1);\r\n this.mouseWheelYSpeed = this.dealParam(options.mouseWheelYSpeed, 1);\r\n this.mouseMoveIsEnable = this.dealParam(options.mouseMoveIsEnable, true);\r\n this.mouseMoveXSpeed = this.dealParam(options.mouseMoveXSpeed, 1);\r\n this.mouseMoveYSpeed = this.dealParam(options.mouseMoveYSpeed, 1);\r\n this.mouseMoveInertiaXDeceleration = this.dealParam(options.mouseMoveInertiaXDeceleration, Infinity);\r\n this.mouseMoveInertiaYDeceleration = this.dealParam(options.mouseMoveInertiaYDeceleration, Infinity);\r\n this.mouseMoveInertiaXMaxSpeed = this.dealParam(options.mouseMoveInertiaXMaxSpeed, this.mouseMoveInertiaXDeceleration);\r\n this.mouseMoveInertiaYMaxSpeed = this.dealParam(options.mouseMoveInertiaYMaxSpeed, this.mouseMoveInertiaYDeceleration);\r\n this.touchIsEnable = this.dealParam(options.touchIsEnable, true);\r\n this.touchXSpeed = this.dealParam(options.touchXSpeed, 1);\r\n this.touchYSpeed = this.dealParam(options.touchYSpeed, 1);\r\n this.touchInertiaXDeceleration = this.dealParam(options.touchInertiaXDeceleration, Infinity);\r\n this.touchInertiaYDeceleration = this.dealParam(options.touchInertiaYDeceleration, Infinity);\r\n this.touchInertiaXMaxSpeed = this.dealParam(options.touchInertiaXMaxSpeed, this.touchInertiaXDeceleration);\r\n this.touchInertiaYMaxSpeed = this.dealParam(options.touchInertiaYMaxSpeed, this.touchInertiaYDeceleration);\r\n this.minScrollTop = this.dealParam(options.minScrollTop, 0);\r\n this.minScrollLeft = this.dealParam(options.minScrollLeft, 0);\r\n this.maxScrollTop = this.dealParam(options.maxScrollTop, Infinity);\r\n this.maxScrollLeft = this.dealParam(options.maxScrollLeft, 0);\r\n }\r\n Options.prototype.dealParam = function (param, defaultValue) {\r\n if (param === undefined || param === null) {\r\n return defaultValue;\r\n }\r\n else {\r\n return param;\r\n }\r\n };\r\n return Options;\r\n}());\r\nexports.Options = Options;\r\nvar ScrollEventObject = /** @class */ (function () {\r\n function ScrollEventObject(\r\n // current total distance to the top and left\r\n scrollTop, scrollLeft, \r\n // latest scroll distance on the x-axis and y-axis\r\n scrollY, scrollX) {\r\n this.scrollTop = scrollTop;\r\n this.scrollLeft = scrollLeft;\r\n this.scrollY = scrollY;\r\n this.scrollX = scrollX;\r\n }\r\n return ScrollEventObject;\r\n}());\r\nexports.ScrollEventObject = ScrollEventObject;\r\n\n\n//# sourceURL=webpack:///./src/model.ts?");

@@ -129,7 +129,7 @@ /***/ }),

\******************************/
/*! exports provided: ScrollSensor */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ScrollSensor\", function() { return ScrollSensor; });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./model */ \"./src/model.ts\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ \"./src/util.ts\");\nfunction _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; }\n\n\n\n\n/**\r\n * Scroll sensor main class\r\n * @event scroll Emit when scroll.\r\n */\n\nclass ScrollSensor extends events__WEBPACK_IMPORTED_MODULE_0__[\"EventEmitter\"] {\n /**\r\n * @param {HTMLElement} element The dom element to create the ScrollSensor instance.\r\n * @param {OptionsInterface} options Options.\r\n * @param {number} initialScrollTop\r\n * @param {number} initialScrollLeft\r\n */\n constructor({\n element,\n options = {},\n initialScrollTop = 0,\n initialScrollLeft = 0\n }) {\n super();\n\n _defineProperty(this, \"element\", void 0);\n\n _defineProperty(this, \"options\", void 0);\n\n _defineProperty(this, \"_scrollTop\", void 0);\n\n _defineProperty(this, \"_scrollLeft\", void 0);\n\n _defineProperty(this, \"mouseIsScrolling\", false);\n\n _defineProperty(this, \"mouseXLastPosition\", void 0);\n\n _defineProperty(this, \"mouseYLastPosition\", void 0);\n\n _defineProperty(this, \"mouseScrollEndInertiaUtil\", new _util__WEBPACK_IMPORTED_MODULE_2__[\"EndInertiaUtil\"]());\n\n _defineProperty(this, \"touchXLastPosition\", void 0);\n\n _defineProperty(this, \"touchYLastPosition\", void 0);\n\n _defineProperty(this, \"touchEndInertiaUtil\", new _util__WEBPACK_IMPORTED_MODULE_2__[\"EndInertiaUtil\"]());\n\n _defineProperty(this, \"handleMousewheel\", event => {\n if (!this.options.mouseWheelIsEnable) {\n return;\n }\n\n this.move(event.deltaX * this.options.mouseWheelXSpeed, event.deltaY * this.options.mouseWheelYSpeed);\n });\n\n _defineProperty(this, \"handleMouseDown\", event => {\n if (!this.options.mouseMoveIsEnable) {\n return;\n }\n\n this.mouseXLastPosition = event.clientX;\n this.mouseYLastPosition = event.clientY;\n this.mouseIsScrolling = true;\n this.mouseScrollEndInertiaUtil.stop();\n });\n\n _defineProperty(this, \"handleMouseMove\", event => {\n if (this.mouseIsScrolling) {\n const xDistance = this.mouseXLastPosition - event.clientX;\n const yDistance = this.mouseYLastPosition - event.clientY;\n this.move(xDistance * this.options.mouseMoveXSpeed, yDistance * this.options.mouseMoveYSpeed);\n this.mouseXLastPosition = event.clientX;\n this.mouseYLastPosition = event.clientY;\n this.mouseScrollEndInertiaUtil.push(this.scrollLeft, this.scrollTop);\n }\n });\n\n _defineProperty(this, \"handleMouseUp\", () => {\n this.mouseIsScrolling = false;\n this.mouseScrollEndInertiaUtil.end();\n });\n\n _defineProperty(this, \"handleTouchStart\", event => {\n if (!this.options.touchIsEnable) {\n return;\n }\n\n this.touchXLastPosition = Math.round(event.touches[0].clientX);\n this.touchYLastPosition = Math.round(event.touches[0].clientY);\n this.touchEndInertiaUtil.stop();\n });\n\n _defineProperty(this, \"handleTouchMove\", event => {\n if (!this.options.touchIsEnable) {\n return;\n }\n\n const clientX = Math.round(event.touches[0].clientX);\n const clientY = Math.round(event.touches[0].clientY);\n const xDistance = this.touchXLastPosition - clientX;\n const yDistance = this.touchYLastPosition - clientY;\n this.move(xDistance, yDistance);\n this.touchXLastPosition = clientX;\n this.touchYLastPosition = clientY;\n this.touchEndInertiaUtil.push(this.scrollLeft, this.scrollTop);\n });\n\n _defineProperty(this, \"handleTouchEnd\", () => {\n this.touchEndInertiaUtil.end();\n });\n\n _defineProperty(this, \"handleInertiaMove\", event => {\n this.move(event.xDistance, event.yDistance);\n });\n\n if (!(element instanceof HTMLElement)) {\n throw new Error('\"element\" param is must an instance of HTMLElement');\n }\n\n this.setOptions(options);\n this.element = element;\n this.scrollTop = initialScrollTop;\n this.scrollLeft = initialScrollLeft;\n this.element.addEventListener('mousewheel', this.handleMousewheel);\n this.element.addEventListener('mousedown', this.handleMouseDown);\n this.element.addEventListener('mousemove', this.handleMouseMove);\n this.element.addEventListener('mouseup', this.handleMouseUp);\n this.element.addEventListener('touchstart', this.handleTouchStart);\n this.element.addEventListener('touchmove', this.handleTouchMove);\n this.element.addEventListener('touchend', this.handleTouchEnd);\n this.mouseScrollEndInertiaUtil.on('inertiaMove', this.handleInertiaMove);\n this.touchEndInertiaUtil.on('inertiaMove', this.handleInertiaMove);\n }\n\n setOptions(options = {}) {\n this.options = new _model__WEBPACK_IMPORTED_MODULE_1__[\"Options\"](options);\n this.mouseScrollEndInertiaUtil.setXDecelerationPerSecond(this.options.mouseMoveInertiaXDeceleration);\n this.mouseScrollEndInertiaUtil.setYDecelerationPerSecond(this.options.mouseMoveInertiaYDeceleration);\n this.mouseScrollEndInertiaUtil.setXMaxSpeed(this.options.mouseMoveInertiaXMaxSpeed);\n this.mouseScrollEndInertiaUtil.setYMaxSpeed(this.options.mouseMoveInertiaYMaxSpeed);\n this.touchEndInertiaUtil.setXDecelerationPerSecond(this.options.touchInertiaXDeceleration);\n this.touchEndInertiaUtil.setYDecelerationPerSecond(this.options.touchInertiaYDeceleration);\n this.touchEndInertiaUtil.setXMaxSpeed(this.options.touchInertiaXMaxSpeed);\n this.touchEndInertiaUtil.setYMaxSpeed(this.options.touchInertiaYMaxSpeed);\n }\n\n set scrollTop(scrollTop) {\n if (scrollTop < this.options.minScrollTop) {\n this._scrollTop = this.options.minScrollTop;\n } else if (scrollTop > this.options.maxScrollTop) {\n this._scrollTop = this.options.maxScrollTop;\n } else {\n this._scrollTop = scrollTop;\n }\n }\n\n get scrollTop() {\n return this._scrollTop;\n }\n\n set scrollLeft(scrollLeft) {\n if (scrollLeft < this.options.minScrollLeft) {\n this._scrollLeft = this.options.minScrollLeft;\n } else if (scrollLeft > this.options.maxScrollLeft) {\n this._scrollLeft = this.options.maxScrollLeft;\n } else {\n this._scrollLeft = scrollLeft;\n }\n }\n\n get scrollLeft() {\n return this._scrollLeft;\n }\n /**\r\n * Release the resources.\r\n */\n\n\n destroy() {\n this.mouseScrollEndInertiaUtil.removeAllListeners();\n this.touchEndInertiaUtil.removeAllListeners();\n this.element.removeEventListener('mousewheel', this.handleMousewheel);\n this.element.removeEventListener('mousedown', this.handleMouseDown);\n this.element.removeEventListener('mousemove', this.handleMouseMove);\n this.element.removeEventListener('mouseup', this.handleMouseUp);\n this.element.removeEventListener('touchstart', this.handleTouchStart);\n this.element.removeEventListener('touchmove', this.handleTouchMove);\n this.element.removeEventListener('touchend', this.handleTouchEnd);\n }\n\n move(xDistance, yDistance) {\n this.scrollLeft = this.scrollLeft + xDistance;\n this.scrollTop = this.scrollTop + yDistance;\n const eventObject = new _model__WEBPACK_IMPORTED_MODULE_1__[\"ScrollEventObject\"](this.scrollTop, this.scrollLeft, yDistance, xDistance);\n this.emit('scroll', eventObject);\n }\n\n}\n\n//# sourceURL=webpack:///./src/scroll-sensor.ts?");
eval("\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar events_1 = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\r\nvar model_1 = __webpack_require__(/*! ./model */ \"./src/model.ts\");\r\nvar util_1 = __webpack_require__(/*! ./util */ \"./src/util.ts\");\r\n/**\r\n * Scroll sensor main class\r\n * @event scroll Emit when scroll.\r\n */\r\nvar ScrollSensor = /** @class */ (function (_super) {\r\n __extends(ScrollSensor, _super);\r\n /**\r\n * @param {HTMLElement} element The dom element to create the ScrollSensor instance.\r\n * @param {OptionsInterface} options Options.\r\n * @param {number} initialScrollTop\r\n * @param {number} initialScrollLeft\r\n */\r\n function ScrollSensor(_a) {\r\n var element = _a.element, _b = _a.options, options = _b === void 0 ? {} : _b, _c = _a.initialScrollTop, initialScrollTop = _c === void 0 ? 0 : _c, _d = _a.initialScrollLeft, initialScrollLeft = _d === void 0 ? 0 : _d;\r\n var _this = _super.call(this) || this;\r\n _this.mouseIsScrolling = false;\r\n _this.mouseScrollEndInertiaUtil = new util_1.EndInertiaUtil();\r\n _this.touchEndInertiaUtil = new util_1.EndInertiaUtil();\r\n _this.handleMousewheel = function (event) {\r\n if (!_this.options.mouseWheelIsEnable) {\r\n return;\r\n }\r\n _this.move(event.deltaX * _this.options.mouseWheelXSpeed, event.deltaY * _this.options.mouseWheelYSpeed);\r\n };\r\n _this.handleMouseDown = function (event) {\r\n if (!_this.options.mouseMoveIsEnable) {\r\n return;\r\n }\r\n _this.mouseXLastPosition = event.clientX;\r\n _this.mouseYLastPosition = event.clientY;\r\n _this.mouseIsScrolling = true;\r\n _this.mouseScrollEndInertiaUtil.stop();\r\n };\r\n _this.handleMouseMove = function (event) {\r\n if (_this.mouseIsScrolling) {\r\n var xDistance = _this.mouseXLastPosition - event.clientX;\r\n var yDistance = _this.mouseYLastPosition - event.clientY;\r\n _this.move(xDistance * _this.options.mouseMoveXSpeed, yDistance * _this.options.mouseMoveYSpeed);\r\n _this.mouseXLastPosition = event.clientX;\r\n _this.mouseYLastPosition = event.clientY;\r\n _this.mouseScrollEndInertiaUtil.push(_this.scrollLeft, _this.scrollTop);\r\n }\r\n };\r\n _this.handleMouseUp = function () {\r\n _this.mouseIsScrolling = false;\r\n _this.mouseScrollEndInertiaUtil.end();\r\n };\r\n _this.handleTouchStart = function (event) {\r\n if (!_this.options.touchIsEnable) {\r\n return;\r\n }\r\n _this.touchXLastPosition = Math.round(event.touches[0].clientX);\r\n _this.touchYLastPosition = Math.round(event.touches[0].clientY);\r\n _this.touchEndInertiaUtil.stop();\r\n };\r\n _this.handleTouchMove = function (event) {\r\n if (!_this.options.touchIsEnable) {\r\n return;\r\n }\r\n var clientX = Math.round(event.touches[0].clientX);\r\n var clientY = Math.round(event.touches[0].clientY);\r\n var xDistance = _this.touchXLastPosition - clientX;\r\n var yDistance = _this.touchYLastPosition - clientY;\r\n _this.move(xDistance, yDistance);\r\n _this.touchXLastPosition = clientX;\r\n _this.touchYLastPosition = clientY;\r\n _this.touchEndInertiaUtil.push(_this.scrollLeft, _this.scrollTop);\r\n };\r\n _this.handleTouchEnd = function () {\r\n _this.touchEndInertiaUtil.end();\r\n };\r\n _this.handleInertiaMove = function (event) {\r\n _this.move(event.xDistance, event.yDistance);\r\n };\r\n if (!(element instanceof HTMLElement)) {\r\n throw new Error('\"element\" param is must an instance of HTMLElement');\r\n }\r\n _this.setOptions(options);\r\n _this.element = element;\r\n _this.scrollTop = initialScrollTop;\r\n _this.scrollLeft = initialScrollLeft;\r\n _this.element.addEventListener('mousewheel', _this.handleMousewheel);\r\n _this.element.addEventListener('mousedown', _this.handleMouseDown);\r\n _this.element.addEventListener('mousemove', _this.handleMouseMove);\r\n _this.element.addEventListener('mouseup', _this.handleMouseUp);\r\n _this.element.addEventListener('touchstart', _this.handleTouchStart);\r\n _this.element.addEventListener('touchmove', _this.handleTouchMove);\r\n _this.element.addEventListener('touchend', _this.handleTouchEnd);\r\n _this.mouseScrollEndInertiaUtil.on('inertiaMove', _this.handleInertiaMove);\r\n _this.touchEndInertiaUtil.on('inertiaMove', _this.handleInertiaMove);\r\n return _this;\r\n }\r\n ScrollSensor.prototype.setOptions = function (options) {\r\n if (options === void 0) { options = {}; }\r\n this.options = new model_1.Options(options);\r\n this.mouseScrollEndInertiaUtil.setXDecelerationPerSecond(this.options.mouseMoveInertiaXDeceleration);\r\n this.mouseScrollEndInertiaUtil.setYDecelerationPerSecond(this.options.mouseMoveInertiaYDeceleration);\r\n this.mouseScrollEndInertiaUtil.setXMaxSpeed(this.options.mouseMoveInertiaXMaxSpeed);\r\n this.mouseScrollEndInertiaUtil.setYMaxSpeed(this.options.mouseMoveInertiaYMaxSpeed);\r\n this.touchEndInertiaUtil.setXDecelerationPerSecond(this.options.touchInertiaXDeceleration);\r\n this.touchEndInertiaUtil.setYDecelerationPerSecond(this.options.touchInertiaYDeceleration);\r\n this.touchEndInertiaUtil.setXMaxSpeed(this.options.touchInertiaXMaxSpeed);\r\n this.touchEndInertiaUtil.setYMaxSpeed(this.options.touchInertiaYMaxSpeed);\r\n };\r\n Object.defineProperty(ScrollSensor.prototype, \"scrollTop\", {\r\n get: function () {\r\n return this._scrollTop;\r\n },\r\n set: function (scrollTop) {\r\n if (scrollTop < this.options.minScrollTop) {\r\n this._scrollTop = this.options.minScrollTop;\r\n }\r\n else if (scrollTop > this.options.maxScrollTop) {\r\n this._scrollTop = this.options.maxScrollTop;\r\n }\r\n else {\r\n this._scrollTop = scrollTop;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ScrollSensor.prototype, \"scrollLeft\", {\r\n get: function () {\r\n return this._scrollLeft;\r\n },\r\n set: function (scrollLeft) {\r\n if (scrollLeft < this.options.minScrollLeft) {\r\n this._scrollLeft = this.options.minScrollLeft;\r\n }\r\n else if (scrollLeft > this.options.maxScrollLeft) {\r\n this._scrollLeft = this.options.maxScrollLeft;\r\n }\r\n else {\r\n this._scrollLeft = scrollLeft;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Release the resources.\r\n */\r\n ScrollSensor.prototype.destroy = function () {\r\n this.mouseScrollEndInertiaUtil.removeAllListeners();\r\n this.touchEndInertiaUtil.removeAllListeners();\r\n this.element.removeEventListener('mousewheel', this.handleMousewheel);\r\n this.element.removeEventListener('mousedown', this.handleMouseDown);\r\n this.element.removeEventListener('mousemove', this.handleMouseMove);\r\n this.element.removeEventListener('mouseup', this.handleMouseUp);\r\n this.element.removeEventListener('touchstart', this.handleTouchStart);\r\n this.element.removeEventListener('touchmove', this.handleTouchMove);\r\n this.element.removeEventListener('touchend', this.handleTouchEnd);\r\n };\r\n ScrollSensor.prototype.move = function (xDistance, yDistance) {\r\n this.scrollLeft = this.scrollLeft + xDistance;\r\n this.scrollTop = this.scrollTop + yDistance;\r\n var eventObject = new model_1.ScrollEventObject(this.scrollTop, this.scrollLeft, yDistance, xDistance);\r\n this.emit('scroll', eventObject);\r\n };\r\n return ScrollSensor;\r\n}(events_1.EventEmitter));\r\nexports.ScrollSensor = ScrollSensor;\r\n\n\n//# sourceURL=webpack:///./src/scroll-sensor.ts?");

@@ -142,7 +142,7 @@ /***/ }),

\*********************/
/*! exports provided: getSign, EndInertiaUtil */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getSign\", function() { return getSign; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"EndInertiaUtil\", function() { return EndInertiaUtil; });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_0__);\nfunction _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; }\n\n\n/**\r\n * Get positive and negative sign of a number.\r\n */\n\nfunction getSign(num) {\n if (num > 0) {\n return 1;\n } else if (num < 0) {\n return -1;\n } else if (num === 0) {\n return 0;\n } else {\n return NaN;\n }\n}\n\nclass PositionStore {\n constructor(endTimeRange) {\n this.endTimeRange = endTimeRange;\n\n _defineProperty(this, \"positions\", []);\n }\n\n filterPositions() {\n const now = new Date();\n this.positions = this.positions.filter(item => {\n return now.getTime() - item[0].getTime() <= this.endTimeRange;\n });\n }\n\n push(position) {\n if (this.positions.length && this.positions[this.positions.length - 1][1] * position < 0) {\n this.clear();\n }\n\n this.positions.push([new Date(), position]);\n this.filterPositions();\n }\n\n getEndSpeed() {\n this.filterPositions();\n\n if (this.positions.length === 0 || this.positions.length === 1) {\n return 0;\n }\n\n const start = this.positions[0];\n const end = this.positions[this.positions.length - 1];\n return (end[1] - start[1]) / ((end[0].getTime() - start[0].getTime()) / 1000);\n }\n\n clear() {\n this.positions = [];\n }\n\n}\n/**\r\n * A util to deal scroll end inertia.\r\n * @event inertiaMove Be emitted continuously after call \"end\" method, until the speed drop to 0.\r\n * Its event object has four property:xSpeed,ySpeed,xDistance,yDistance.\r\n */\n\n\nclass EndInertiaUtil extends events__WEBPACK_IMPORTED_MODULE_0__[\"EventEmitter\"] {\n constructor(endTimeRange = 200, xDecelerationPerSecond = Infinity, yDecelerationPerSecond = Infinity, xMaxSpeed = Infinity, yMaxSpeed = Infinity) {\n super();\n this.xDecelerationPerSecond = xDecelerationPerSecond;\n this.yDecelerationPerSecond = yDecelerationPerSecond;\n this.xMaxSpeed = xMaxSpeed;\n this.yMaxSpeed = yMaxSpeed;\n\n _defineProperty(this, \"xPositionStore\", void 0);\n\n _defineProperty(this, \"yPositionStore\", void 0);\n\n _defineProperty(this, \"timer\", void 0);\n\n this.xPositionStore = new PositionStore(endTimeRange);\n this.yPositionStore = new PositionStore(endTimeRange);\n }\n\n setEndTimeRange(endTimeRange) {\n this.xPositionStore.endTimeRange = endTimeRange;\n this.yPositionStore.endTimeRange = endTimeRange;\n }\n\n setXDecelerationPerSecond(xDecelerationPerSecond) {\n this.xDecelerationPerSecond = xDecelerationPerSecond;\n }\n\n setYDecelerationPerSecond(yDecelerationPerSecond) {\n this.yDecelerationPerSecond = yDecelerationPerSecond;\n }\n\n setXMaxSpeed(xMaxSpeed) {\n this.xMaxSpeed = xMaxSpeed;\n }\n\n setYMaxSpeed(yMaxSpeed) {\n this.yMaxSpeed = yMaxSpeed;\n }\n /**\r\n * Push a move position.It will be used to calculate the end speed.\r\n */\n\n\n push(positionX, positionY) {\n this.xPositionStore.push(positionX);\n this.yPositionStore.push(positionY);\n }\n /**\r\n * End a series of position push and start to calculate inertia move distance and emit \"inertiaMove\" event.\r\n */\n\n\n end() {\n if (this.timer) {\n window.clearInterval(this.timer);\n }\n\n const originalXSpeed = this.dealOriginalSpeed(this.xPositionStore.getEndSpeed(), this.xMaxSpeed);\n const originalYSpeed = this.dealOriginalSpeed(this.yPositionStore.getEndSpeed(), this.yMaxSpeed);\n const xDecelerationPerSecond = getSign(originalXSpeed) === 0 ? 0 : getSign(originalXSpeed) * this.xDecelerationPerSecond;\n const yDecelerationPerSecond = getSign(originalYSpeed) === 0 ? 0 : getSign(originalYSpeed) * this.yDecelerationPerSecond;\n let xSpeed = originalXSpeed;\n let ySpeed = originalYSpeed;\n let time = Date.now();\n this.timer = setInterval(() => {\n const pastSeconds = (Date.now() - time) / 1000;\n\n if (pastSeconds === 0) {\n return;\n }\n\n xSpeed = xSpeed - pastSeconds * xDecelerationPerSecond;\n ySpeed = ySpeed - pastSeconds * yDecelerationPerSecond;\n time = Date.now();\n\n if (xSpeed * originalXSpeed > 0 || ySpeed * originalYSpeed > 0) {\n if (isNaN(xSpeed * originalXSpeed) || xSpeed * originalXSpeed < 0) {\n xSpeed = 0;\n }\n\n if (isNaN(xSpeed * originalYSpeed) || ySpeed * originalYSpeed < 0) {\n ySpeed = 0;\n }\n\n this.emit('inertiaMove', {\n xSpeed,\n ySpeed,\n xDistance: xSpeed * pastSeconds,\n yDistance: ySpeed * pastSeconds\n });\n } else {\n this.stop();\n }\n });\n }\n /**\r\n * Stop the inertia move.\r\n * It also stop to emit the \"inertiaMove\" event.\r\n */\n\n\n stop() {\n this.xPositionStore.clear();\n this.yPositionStore.clear();\n window.clearInterval(this.timer);\n this.timer = null;\n }\n\n dealOriginalSpeed(speed, maxSpeed) {\n if (Math.abs(speed) > maxSpeed) {\n return getSign(speed) * maxSpeed;\n } else {\n return speed;\n }\n }\n\n}\n\n//# sourceURL=webpack:///./src/util.ts?");
eval("\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar events_1 = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\r\n/**\r\n * Get positive and negative sign of a number.\r\n */\r\nfunction getSign(num) {\r\n if (num > 0) {\r\n return 1;\r\n }\r\n else if (num < 0) {\r\n return -1;\r\n }\r\n else if (num === 0) {\r\n return 0;\r\n }\r\n else {\r\n return NaN;\r\n }\r\n}\r\nexports.getSign = getSign;\r\nvar PositionStore = /** @class */ (function () {\r\n function PositionStore(endTimeRange) {\r\n this.endTimeRange = endTimeRange;\r\n this.positions = [];\r\n }\r\n PositionStore.prototype.filterPositions = function () {\r\n var _this = this;\r\n var now = new Date();\r\n this.positions = this.positions.filter(function (item) {\r\n return now.getTime() - item[0].getTime() <= _this.endTimeRange;\r\n });\r\n };\r\n PositionStore.prototype.push = function (position) {\r\n if (this.positions.length && (this.positions[this.positions.length - 1][1] * position < 0)) {\r\n this.clear();\r\n }\r\n this.positions.push([new Date(), position]);\r\n this.filterPositions();\r\n };\r\n PositionStore.prototype.getEndSpeed = function () {\r\n this.filterPositions();\r\n if (this.positions.length === 0 || this.positions.length === 1) {\r\n return 0;\r\n }\r\n var start = this.positions[0];\r\n var end = this.positions[this.positions.length - 1];\r\n return (end[1] - start[1]) / ((end[0].getTime() - start[0].getTime()) / 1000);\r\n };\r\n PositionStore.prototype.clear = function () {\r\n this.positions = [];\r\n };\r\n return PositionStore;\r\n}());\r\n/**\r\n * A util to deal scroll end inertia.\r\n * @event inertiaMove Be emitted continuously after call \"end\" method, until the speed drop to 0.\r\n * Its event object has four property:xSpeed,ySpeed,xDistance,yDistance.\r\n */\r\nvar EndInertiaUtil = /** @class */ (function (_super) {\r\n __extends(EndInertiaUtil, _super);\r\n function EndInertiaUtil(endTimeRange, xDecelerationPerSecond, yDecelerationPerSecond, xMaxSpeed, yMaxSpeed) {\r\n if (endTimeRange === void 0) { endTimeRange = 200; }\r\n if (xDecelerationPerSecond === void 0) { xDecelerationPerSecond = Infinity; }\r\n if (yDecelerationPerSecond === void 0) { yDecelerationPerSecond = Infinity; }\r\n if (xMaxSpeed === void 0) { xMaxSpeed = Infinity; }\r\n if (yMaxSpeed === void 0) { yMaxSpeed = Infinity; }\r\n var _this = _super.call(this) || this;\r\n _this.xDecelerationPerSecond = xDecelerationPerSecond;\r\n _this.yDecelerationPerSecond = yDecelerationPerSecond;\r\n _this.xMaxSpeed = xMaxSpeed;\r\n _this.yMaxSpeed = yMaxSpeed;\r\n _this.xPositionStore = new PositionStore(endTimeRange);\r\n _this.yPositionStore = new PositionStore(endTimeRange);\r\n return _this;\r\n }\r\n EndInertiaUtil.prototype.setEndTimeRange = function (endTimeRange) {\r\n this.xPositionStore.endTimeRange = endTimeRange;\r\n this.yPositionStore.endTimeRange = endTimeRange;\r\n };\r\n EndInertiaUtil.prototype.setXDecelerationPerSecond = function (xDecelerationPerSecond) {\r\n this.xDecelerationPerSecond = xDecelerationPerSecond;\r\n };\r\n EndInertiaUtil.prototype.setYDecelerationPerSecond = function (yDecelerationPerSecond) {\r\n this.yDecelerationPerSecond = yDecelerationPerSecond;\r\n };\r\n EndInertiaUtil.prototype.setXMaxSpeed = function (xMaxSpeed) {\r\n this.xMaxSpeed = xMaxSpeed;\r\n };\r\n EndInertiaUtil.prototype.setYMaxSpeed = function (yMaxSpeed) {\r\n this.yMaxSpeed = yMaxSpeed;\r\n };\r\n /**\r\n * Push a move position.It will be used to calculate the end speed.\r\n */\r\n EndInertiaUtil.prototype.push = function (positionX, positionY) {\r\n this.xPositionStore.push(positionX);\r\n this.yPositionStore.push(positionY);\r\n };\r\n /**\r\n * End a series of position push and start to calculate inertia move distance and emit \"inertiaMove\" event.\r\n */\r\n EndInertiaUtil.prototype.end = function () {\r\n var _this = this;\r\n if (this.timer) {\r\n window.clearInterval(this.timer);\r\n }\r\n var originalXSpeed = this.dealOriginalSpeed(this.xPositionStore.getEndSpeed(), this.xMaxSpeed);\r\n var originalYSpeed = this.dealOriginalSpeed(this.yPositionStore.getEndSpeed(), this.yMaxSpeed);\r\n var xDecelerationPerSecond = getSign(originalXSpeed) === 0 ? 0 : getSign(originalXSpeed) * this.xDecelerationPerSecond;\r\n var yDecelerationPerSecond = getSign(originalYSpeed) === 0 ? 0 : getSign(originalYSpeed) * this.yDecelerationPerSecond;\r\n var xSpeed = originalXSpeed;\r\n var ySpeed = originalYSpeed;\r\n var time = Date.now();\r\n this.timer = setInterval(function () {\r\n var pastSeconds = (Date.now() - time) / 1000;\r\n if (pastSeconds === 0) {\r\n return;\r\n }\r\n xSpeed = xSpeed - pastSeconds * xDecelerationPerSecond;\r\n ySpeed = ySpeed - pastSeconds * yDecelerationPerSecond;\r\n time = Date.now();\r\n if (xSpeed * originalXSpeed > 0 || ySpeed * originalYSpeed > 0) {\r\n if (isNaN(xSpeed * originalXSpeed) || xSpeed * originalXSpeed < 0) {\r\n xSpeed = 0;\r\n }\r\n if (isNaN(xSpeed * originalYSpeed) || ySpeed * originalYSpeed < 0) {\r\n ySpeed = 0;\r\n }\r\n _this.emit('inertiaMove', {\r\n xSpeed: xSpeed,\r\n ySpeed: ySpeed,\r\n xDistance: xSpeed * pastSeconds,\r\n yDistance: ySpeed * pastSeconds,\r\n });\r\n }\r\n else {\r\n _this.stop();\r\n }\r\n });\r\n };\r\n /**\r\n * Stop the inertia move.\r\n * It also stop to emit the \"inertiaMove\" event.\r\n */\r\n EndInertiaUtil.prototype.stop = function () {\r\n this.xPositionStore.clear();\r\n this.yPositionStore.clear();\r\n window.clearInterval(this.timer);\r\n this.timer = null;\r\n };\r\n EndInertiaUtil.prototype.dealOriginalSpeed = function (speed, maxSpeed) {\r\n if (Math.abs(speed) > maxSpeed) {\r\n return getSign(speed) * maxSpeed;\r\n }\r\n else {\r\n return speed;\r\n }\r\n };\r\n return EndInertiaUtil;\r\n}(events_1.EventEmitter));\r\nexports.EndInertiaUtil = EndInertiaUtil;\r\n\n\n//# sourceURL=webpack:///./src/util.ts?");

@@ -149,0 +149,0 @@ /***/ })

@@ -1,1 +0,1 @@

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(window,(function(){return function(e){var t={};function i(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,o){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(o,n,function(t){return e[t]}.bind(null,n));return o},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=1)}([function(e,t,i){"use strict";var o,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};o=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function h(){h.init.call(this)}e.exports=h,h.EventEmitter=h,h.prototype._events=void 0,h.prototype._eventsCount=0,h.prototype._maxListeners=void 0;var l=10;function a(e){return void 0===e._maxListeners?h.defaultMaxListeners:e._maxListeners}function u(e,t,i,o){var n,s,r,h;if("function"!=typeof i)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i);if(void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),r=s[t]),void 0===r)r=s[t]=i,++e._eventsCount;else if("function"==typeof r?r=s[t]=o?[i,r]:[r,i]:o?r.unshift(i):r.push(i),(n=a(e))>0&&r.length>n&&!r.warned){r.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=r.length,h=l,console&&console.warn&&console.warn(h)}return e}function c(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,e))}function d(e,t,i){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},n=c.bind(o);return n.listener=i,o.wrapFn=n,n}function p(e,t,i){var o=e._events;if(void 0===o)return[];var n=o[t];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(n):v(n,n.length)}function m(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function v(e,t){for(var i=new Array(t),o=0;o<t;++o)i[o]=e[o];return i}Object.defineProperty(h,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e}}),h.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},h.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},h.prototype.getMaxListeners=function(){return a(this)},h.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var o="error"===e,n=this._events;if(void 0!==n)o=o&&void 0===n.error;else if(!o)return!1;if(o){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var h=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw h.context=r,h}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)s(l,this,t);else{var a=l.length,u=v(l,a);for(i=0;i<a;++i)s(u[i],this,t)}return!0},h.prototype.addListener=function(e,t){return u(this,e,t,!1)},h.prototype.on=h.prototype.addListener,h.prototype.prependListener=function(e,t){return u(this,e,t,!0)},h.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,d(this,e,t)),this},h.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,d(this,e,t)),this},h.prototype.removeListener=function(e,t){var i,o,n,s,r;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(o=this._events))return this;if(void 0===(i=o[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(n=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){r=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,n),1===i.length&&(o[e]=i[0]),void 0!==o.removeListener&&this.emit("removeListener",e,r||t)}return this},h.prototype.off=h.prototype.removeListener,h.prototype.removeAllListeners=function(e){var t,i,o;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var n,s=Object.keys(i);for(o=0;o<s.length;++o)"removeListener"!==(n=s[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);return this},h.prototype.listeners=function(e){return p(this,e,!0)},h.prototype.rawListeners=function(e){return p(this,e,!1)},h.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},h.prototype.listenerCount=m,h.prototype.eventNames=function(){return this._eventsCount>0?o(this._events):[]}},function(e,t,i){"use strict";i.r(t);var o=i(0);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class s{constructor(e={}){n(this,"mouseWheelIsEnable",void 0),n(this,"mouseWheelXSpeed",void 0),n(this,"mouseWheelYSpeed",void 0),n(this,"mouseMoveIsEnable",void 0),n(this,"mouseMoveXSpeed",void 0),n(this,"mouseMoveYSpeed",void 0),n(this,"mouseMoveInertiaXDeceleration",void 0),n(this,"mouseMoveInertiaYDeceleration",void 0),n(this,"mouseMoveInertiaXMaxSpeed",void 0),n(this,"mouseMoveInertiaYMaxSpeed",void 0),n(this,"touchIsEnable",void 0),n(this,"touchXSpeed",void 0),n(this,"touchYSpeed",void 0),n(this,"touchInertiaXDeceleration",void 0),n(this,"touchInertiaYDeceleration",void 0),n(this,"touchInertiaXMaxSpeed",void 0),n(this,"touchInertiaYMaxSpeed",void 0),n(this,"minScrollTop",void 0),n(this,"minScrollLeft",void 0),n(this,"maxScrollTop",void 0),n(this,"maxScrollLeft",void 0),this.mouseWheelIsEnable=this.dealParam(e.mouseWheelIsEnable,!0),this.mouseWheelXSpeed=this.dealParam(e.mouseWheelXSpeed,1),this.mouseWheelYSpeed=this.dealParam(e.mouseWheelYSpeed,1),this.mouseMoveIsEnable=this.dealParam(e.mouseMoveIsEnable,!0),this.mouseMoveXSpeed=this.dealParam(e.mouseMoveXSpeed,1),this.mouseMoveYSpeed=this.dealParam(e.mouseMoveYSpeed,1),this.mouseMoveInertiaXDeceleration=this.dealParam(e.mouseMoveInertiaXDeceleration,1/0),this.mouseMoveInertiaYDeceleration=this.dealParam(e.mouseMoveInertiaYDeceleration,1/0),this.mouseMoveInertiaXMaxSpeed=this.dealParam(e.mouseMoveInertiaXMaxSpeed,this.mouseMoveInertiaXDeceleration),this.mouseMoveInertiaYMaxSpeed=this.dealParam(e.mouseMoveInertiaYMaxSpeed,this.mouseMoveInertiaYDeceleration),this.touchIsEnable=this.dealParam(e.touchIsEnable,!0),this.touchXSpeed=this.dealParam(e.touchXSpeed,1),this.touchYSpeed=this.dealParam(e.touchYSpeed,1),this.touchInertiaXDeceleration=this.dealParam(e.touchInertiaXDeceleration,1/0),this.touchInertiaYDeceleration=this.dealParam(e.touchInertiaYDeceleration,1/0),this.touchInertiaXMaxSpeed=this.dealParam(e.touchInertiaXMaxSpeed,this.touchInertiaXDeceleration),this.touchInertiaYMaxSpeed=this.dealParam(e.touchInertiaYMaxSpeed,this.touchInertiaYDeceleration),this.minScrollTop=this.dealParam(e.minScrollTop,0),this.minScrollLeft=this.dealParam(e.minScrollLeft,0),this.maxScrollTop=this.dealParam(e.maxScrollTop,1/0),this.maxScrollLeft=this.dealParam(e.maxScrollLeft,0)}dealParam(e,t){return null==e?t:e}}class r{constructor(e,t,i,o){this.scrollTop=e,this.scrollLeft=t,this.scrollY=i,this.scrollX=o}}function h(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e){return e>0?1:e<0?-1:0===e?0:NaN}class a{constructor(e){this.endTimeRange=e,h(this,"positions",[])}filterPositions(){const e=new Date;this.positions=this.positions.filter(t=>e.getTime()-t[0].getTime()<=this.endTimeRange)}push(e){this.positions.length&&this.positions[this.positions.length-1][1]*e<0&&this.clear(),this.positions.push([new Date,e]),this.filterPositions()}getEndSpeed(){if(this.filterPositions(),0===this.positions.length||1===this.positions.length)return 0;const e=this.positions[0],t=this.positions[this.positions.length-1];return(t[1]-e[1])/((t[0].getTime()-e[0].getTime())/1e3)}clear(){this.positions=[]}}class u extends o.EventEmitter{constructor(e=200,t=1/0,i=1/0,o=1/0,n=1/0){super(),this.xDecelerationPerSecond=t,this.yDecelerationPerSecond=i,this.xMaxSpeed=o,this.yMaxSpeed=n,h(this,"xPositionStore",void 0),h(this,"yPositionStore",void 0),h(this,"timer",void 0),this.xPositionStore=new a(e),this.yPositionStore=new a(e)}setEndTimeRange(e){this.xPositionStore.endTimeRange=e,this.yPositionStore.endTimeRange=e}setXDecelerationPerSecond(e){this.xDecelerationPerSecond=e}setYDecelerationPerSecond(e){this.yDecelerationPerSecond=e}setXMaxSpeed(e){this.xMaxSpeed=e}setYMaxSpeed(e){this.yMaxSpeed=e}push(e,t){this.xPositionStore.push(e),this.yPositionStore.push(t)}end(){this.timer&&window.clearInterval(this.timer);const e=this.dealOriginalSpeed(this.xPositionStore.getEndSpeed(),this.xMaxSpeed),t=this.dealOriginalSpeed(this.yPositionStore.getEndSpeed(),this.yMaxSpeed),i=0===l(e)?0:l(e)*this.xDecelerationPerSecond,o=0===l(t)?0:l(t)*this.yDecelerationPerSecond;let n=e,s=t,r=Date.now();this.timer=setInterval(()=>{const h=(Date.now()-r)/1e3;0!==h&&(n-=h*i,s-=h*o,r=Date.now(),n*e>0||s*t>0?((isNaN(n*e)||n*e<0)&&(n=0),(isNaN(n*t)||s*t<0)&&(s=0),this.emit("inertiaMove",{xSpeed:n,ySpeed:s,xDistance:n*h,yDistance:s*h})):this.stop())})}stop(){this.xPositionStore.clear(),this.yPositionStore.clear(),window.clearInterval(this.timer),this.timer=null}dealOriginalSpeed(e,t){return Math.abs(e)>t?l(e)*t:e}}function c(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}i.d(t,"ScrollSensor",(function(){return d}));class d extends o.EventEmitter{constructor({element:e,options:t={},initialScrollTop:i=0,initialScrollLeft:o=0}){if(super(),c(this,"element",void 0),c(this,"options",void 0),c(this,"_scrollTop",void 0),c(this,"_scrollLeft",void 0),c(this,"mouseIsScrolling",!1),c(this,"mouseXLastPosition",void 0),c(this,"mouseYLastPosition",void 0),c(this,"mouseScrollEndInertiaUtil",new u),c(this,"touchXLastPosition",void 0),c(this,"touchYLastPosition",void 0),c(this,"touchEndInertiaUtil",new u),c(this,"handleMousewheel",e=>{this.options.mouseWheelIsEnable&&this.move(e.deltaX*this.options.mouseWheelXSpeed,e.deltaY*this.options.mouseWheelYSpeed)}),c(this,"handleMouseDown",e=>{this.options.mouseMoveIsEnable&&(this.mouseXLastPosition=e.clientX,this.mouseYLastPosition=e.clientY,this.mouseIsScrolling=!0,this.mouseScrollEndInertiaUtil.stop())}),c(this,"handleMouseMove",e=>{if(this.mouseIsScrolling){const t=this.mouseXLastPosition-e.clientX,i=this.mouseYLastPosition-e.clientY;this.move(t*this.options.mouseMoveXSpeed,i*this.options.mouseMoveYSpeed),this.mouseXLastPosition=e.clientX,this.mouseYLastPosition=e.clientY,this.mouseScrollEndInertiaUtil.push(this.scrollLeft,this.scrollTop)}}),c(this,"handleMouseUp",()=>{this.mouseIsScrolling=!1,this.mouseScrollEndInertiaUtil.end()}),c(this,"handleTouchStart",e=>{this.options.touchIsEnable&&(this.touchXLastPosition=Math.round(e.touches[0].clientX),this.touchYLastPosition=Math.round(e.touches[0].clientY),this.touchEndInertiaUtil.stop())}),c(this,"handleTouchMove",e=>{if(!this.options.touchIsEnable)return;const t=Math.round(e.touches[0].clientX),i=Math.round(e.touches[0].clientY),o=this.touchXLastPosition-t,n=this.touchYLastPosition-i;this.move(o,n),this.touchXLastPosition=t,this.touchYLastPosition=i,this.touchEndInertiaUtil.push(this.scrollLeft,this.scrollTop)}),c(this,"handleTouchEnd",()=>{this.touchEndInertiaUtil.end()}),c(this,"handleInertiaMove",e=>{this.move(e.xDistance,e.yDistance)}),!(e instanceof HTMLElement))throw new Error('"element" param is must an instance of HTMLElement');this.setOptions(t),this.element=e,this.scrollTop=i,this.scrollLeft=o,this.element.addEventListener("mousewheel",this.handleMousewheel),this.element.addEventListener("mousedown",this.handleMouseDown),this.element.addEventListener("mousemove",this.handleMouseMove),this.element.addEventListener("mouseup",this.handleMouseUp),this.element.addEventListener("touchstart",this.handleTouchStart),this.element.addEventListener("touchmove",this.handleTouchMove),this.element.addEventListener("touchend",this.handleTouchEnd),this.mouseScrollEndInertiaUtil.on("inertiaMove",this.handleInertiaMove),this.touchEndInertiaUtil.on("inertiaMove",this.handleInertiaMove)}setOptions(e={}){this.options=new s(e),this.mouseScrollEndInertiaUtil.setXDecelerationPerSecond(this.options.mouseMoveInertiaXDeceleration),this.mouseScrollEndInertiaUtil.setYDecelerationPerSecond(this.options.mouseMoveInertiaYDeceleration),this.mouseScrollEndInertiaUtil.setXMaxSpeed(this.options.mouseMoveInertiaXMaxSpeed),this.mouseScrollEndInertiaUtil.setYMaxSpeed(this.options.mouseMoveInertiaYMaxSpeed),this.touchEndInertiaUtil.setXDecelerationPerSecond(this.options.touchInertiaXDeceleration),this.touchEndInertiaUtil.setYDecelerationPerSecond(this.options.touchInertiaYDeceleration),this.touchEndInertiaUtil.setXMaxSpeed(this.options.touchInertiaXMaxSpeed),this.touchEndInertiaUtil.setYMaxSpeed(this.options.touchInertiaYMaxSpeed)}set scrollTop(e){e<this.options.minScrollTop?this._scrollTop=this.options.minScrollTop:e>this.options.maxScrollTop?this._scrollTop=this.options.maxScrollTop:this._scrollTop=e}get scrollTop(){return this._scrollTop}set scrollLeft(e){e<this.options.minScrollLeft?this._scrollLeft=this.options.minScrollLeft:e>this.options.maxScrollLeft?this._scrollLeft=this.options.maxScrollLeft:this._scrollLeft=e}get scrollLeft(){return this._scrollLeft}destroy(){this.mouseScrollEndInertiaUtil.removeAllListeners(),this.touchEndInertiaUtil.removeAllListeners(),this.element.removeEventListener("mousewheel",this.handleMousewheel),this.element.removeEventListener("mousedown",this.handleMouseDown),this.element.removeEventListener("mousemove",this.handleMouseMove),this.element.removeEventListener("mouseup",this.handleMouseUp),this.element.removeEventListener("touchstart",this.handleTouchStart),this.element.removeEventListener("touchmove",this.handleTouchMove),this.element.removeEventListener("touchend",this.handleTouchEnd)}move(e,t){this.scrollLeft=this.scrollLeft+e,this.scrollTop=this.scrollTop+t;const i=new r(this.scrollTop,this.scrollLeft,t,e);this.emit("scroll",i)}}}])}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";var o,i="object"==typeof Reflect?Reflect:null,r=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};o=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function l(){l.init.call(this)}e.exports=l,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var a=10;function u(e){return void 0===e._maxListeners?l.defaultMaxListeners:e._maxListeners}function c(e,t,n,o){var i,r,s,l;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),s=r[t]),void 0===s)s=r[t]=n,++e._eventsCount;else if("function"==typeof s?s=r[t]=o?[n,s]:[s,n]:o?s.unshift(n):s.push(n),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,l=a,console&&console.warn&&console.warn(l)}return e}function h(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,r(this.listener,this.target,e))}function p(e,t,n){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=h.bind(o);return i.listener=n,o.wrapFn=i,i}function d(e,t,n){var o=e._events;if(void 0===o)return[];var i=o[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):m(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),o=0;o<t;++o)n[o]=e[o];return n}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),l.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},l.prototype.getMaxListeners=function(){return u(this)},l.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var l=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw l.context=s,l}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)r(a,this,t);else{var u=a.length,c=m(a,u);for(n=0;n<u;++n)r(c[n],this,t)}return!0},l.prototype.addListener=function(e,t){return c(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return c(this,e,t,!0)},l.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,p(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,p(this,e,t)),this},l.prototype.removeListener=function(e,t){var n,o,i,r,s;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(o=this._events))return this;if(void 0===(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){s=n[r].listener,i=r;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(o[e]=n[0]),void 0!==o.removeListener&&this.emit("removeListener",e,s||t)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(e){var t,n,o;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,r=Object.keys(n);for(o=0;o<r.length;++o)"removeListener"!==(i=r[o])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);return this},l.prototype.listeners=function(e){return d(this,e,!0)},l.prototype.rawListeners=function(e){return d(this,e,!1)},l.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},l.prototype.listenerCount=f,l.prototype.eventNames=function(){return this._eventsCount>0?o(this._events):[]}},function(e,t,n){"use strict";var o,i=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),s=n(2),l=n(3),a=function(e){function t(t){var n=t.element,o=t.options,i=void 0===o?{}:o,r=t.initialScrollTop,s=void 0===r?0:r,a=t.initialScrollLeft,u=void 0===a?0:a,c=e.call(this)||this;if(c.mouseIsScrolling=!1,c.mouseScrollEndInertiaUtil=new l.EndInertiaUtil,c.touchEndInertiaUtil=new l.EndInertiaUtil,c.handleMousewheel=function(e){c.options.mouseWheelIsEnable&&c.move(e.deltaX*c.options.mouseWheelXSpeed,e.deltaY*c.options.mouseWheelYSpeed)},c.handleMouseDown=function(e){c.options.mouseMoveIsEnable&&(c.mouseXLastPosition=e.clientX,c.mouseYLastPosition=e.clientY,c.mouseIsScrolling=!0,c.mouseScrollEndInertiaUtil.stop())},c.handleMouseMove=function(e){if(c.mouseIsScrolling){var t=c.mouseXLastPosition-e.clientX,n=c.mouseYLastPosition-e.clientY;c.move(t*c.options.mouseMoveXSpeed,n*c.options.mouseMoveYSpeed),c.mouseXLastPosition=e.clientX,c.mouseYLastPosition=e.clientY,c.mouseScrollEndInertiaUtil.push(c.scrollLeft,c.scrollTop)}},c.handleMouseUp=function(){c.mouseIsScrolling=!1,c.mouseScrollEndInertiaUtil.end()},c.handleTouchStart=function(e){c.options.touchIsEnable&&(c.touchXLastPosition=Math.round(e.touches[0].clientX),c.touchYLastPosition=Math.round(e.touches[0].clientY),c.touchEndInertiaUtil.stop())},c.handleTouchMove=function(e){if(c.options.touchIsEnable){var t=Math.round(e.touches[0].clientX),n=Math.round(e.touches[0].clientY),o=c.touchXLastPosition-t,i=c.touchYLastPosition-n;c.move(o,i),c.touchXLastPosition=t,c.touchYLastPosition=n,c.touchEndInertiaUtil.push(c.scrollLeft,c.scrollTop)}},c.handleTouchEnd=function(){c.touchEndInertiaUtil.end()},c.handleInertiaMove=function(e){c.move(e.xDistance,e.yDistance)},!(n instanceof HTMLElement))throw new Error('"element" param is must an instance of HTMLElement');return c.setOptions(i),c.element=n,c.scrollTop=s,c.scrollLeft=u,c.element.addEventListener("mousewheel",c.handleMousewheel),c.element.addEventListener("mousedown",c.handleMouseDown),c.element.addEventListener("mousemove",c.handleMouseMove),c.element.addEventListener("mouseup",c.handleMouseUp),c.element.addEventListener("touchstart",c.handleTouchStart),c.element.addEventListener("touchmove",c.handleTouchMove),c.element.addEventListener("touchend",c.handleTouchEnd),c.mouseScrollEndInertiaUtil.on("inertiaMove",c.handleInertiaMove),c.touchEndInertiaUtil.on("inertiaMove",c.handleInertiaMove),c}return i(t,e),t.prototype.setOptions=function(e){void 0===e&&(e={}),this.options=new s.Options(e),this.mouseScrollEndInertiaUtil.setXDecelerationPerSecond(this.options.mouseMoveInertiaXDeceleration),this.mouseScrollEndInertiaUtil.setYDecelerationPerSecond(this.options.mouseMoveInertiaYDeceleration),this.mouseScrollEndInertiaUtil.setXMaxSpeed(this.options.mouseMoveInertiaXMaxSpeed),this.mouseScrollEndInertiaUtil.setYMaxSpeed(this.options.mouseMoveInertiaYMaxSpeed),this.touchEndInertiaUtil.setXDecelerationPerSecond(this.options.touchInertiaXDeceleration),this.touchEndInertiaUtil.setYDecelerationPerSecond(this.options.touchInertiaYDeceleration),this.touchEndInertiaUtil.setXMaxSpeed(this.options.touchInertiaXMaxSpeed),this.touchEndInertiaUtil.setYMaxSpeed(this.options.touchInertiaYMaxSpeed)},Object.defineProperty(t.prototype,"scrollTop",{get:function(){return this._scrollTop},set:function(e){e<this.options.minScrollTop?this._scrollTop=this.options.minScrollTop:e>this.options.maxScrollTop?this._scrollTop=this.options.maxScrollTop:this._scrollTop=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollLeft",{get:function(){return this._scrollLeft},set:function(e){e<this.options.minScrollLeft?this._scrollLeft=this.options.minScrollLeft:e>this.options.maxScrollLeft?this._scrollLeft=this.options.maxScrollLeft:this._scrollLeft=e},enumerable:!0,configurable:!0}),t.prototype.destroy=function(){this.mouseScrollEndInertiaUtil.removeAllListeners(),this.touchEndInertiaUtil.removeAllListeners(),this.element.removeEventListener("mousewheel",this.handleMousewheel),this.element.removeEventListener("mousedown",this.handleMouseDown),this.element.removeEventListener("mousemove",this.handleMouseMove),this.element.removeEventListener("mouseup",this.handleMouseUp),this.element.removeEventListener("touchstart",this.handleTouchStart),this.element.removeEventListener("touchmove",this.handleTouchMove),this.element.removeEventListener("touchend",this.handleTouchEnd)},t.prototype.move=function(e,t){this.scrollLeft=this.scrollLeft+e,this.scrollTop=this.scrollTop+t;var n=new s.ScrollEventObject(this.scrollTop,this.scrollLeft,t,e);this.emit("scroll",n)},t}(r.EventEmitter);t.ScrollSensor=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){void 0===e&&(e={}),this.mouseWheelIsEnable=this.dealParam(e.mouseWheelIsEnable,!0),this.mouseWheelXSpeed=this.dealParam(e.mouseWheelXSpeed,1),this.mouseWheelYSpeed=this.dealParam(e.mouseWheelYSpeed,1),this.mouseMoveIsEnable=this.dealParam(e.mouseMoveIsEnable,!0),this.mouseMoveXSpeed=this.dealParam(e.mouseMoveXSpeed,1),this.mouseMoveYSpeed=this.dealParam(e.mouseMoveYSpeed,1),this.mouseMoveInertiaXDeceleration=this.dealParam(e.mouseMoveInertiaXDeceleration,1/0),this.mouseMoveInertiaYDeceleration=this.dealParam(e.mouseMoveInertiaYDeceleration,1/0),this.mouseMoveInertiaXMaxSpeed=this.dealParam(e.mouseMoveInertiaXMaxSpeed,this.mouseMoveInertiaXDeceleration),this.mouseMoveInertiaYMaxSpeed=this.dealParam(e.mouseMoveInertiaYMaxSpeed,this.mouseMoveInertiaYDeceleration),this.touchIsEnable=this.dealParam(e.touchIsEnable,!0),this.touchXSpeed=this.dealParam(e.touchXSpeed,1),this.touchYSpeed=this.dealParam(e.touchYSpeed,1),this.touchInertiaXDeceleration=this.dealParam(e.touchInertiaXDeceleration,1/0),this.touchInertiaYDeceleration=this.dealParam(e.touchInertiaYDeceleration,1/0),this.touchInertiaXMaxSpeed=this.dealParam(e.touchInertiaXMaxSpeed,this.touchInertiaXDeceleration),this.touchInertiaYMaxSpeed=this.dealParam(e.touchInertiaYMaxSpeed,this.touchInertiaYDeceleration),this.minScrollTop=this.dealParam(e.minScrollTop,0),this.minScrollLeft=this.dealParam(e.minScrollLeft,0),this.maxScrollTop=this.dealParam(e.maxScrollTop,1/0),this.maxScrollLeft=this.dealParam(e.maxScrollLeft,0)}return e.prototype.dealParam=function(e,t){return null==e?t:e},e}();t.Options=o;var i=function(e,t,n,o){this.scrollTop=e,this.scrollLeft=t,this.scrollY=n,this.scrollX=o};t.ScrollEventObject=i},function(e,t,n){"use strict";var o,i=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function s(e){return e>0?1:e<0?-1:0===e?0:NaN}t.getSign=s;var l=function(){function e(e){this.endTimeRange=e,this.positions=[]}return e.prototype.filterPositions=function(){var e=this,t=new Date;this.positions=this.positions.filter((function(n){return t.getTime()-n[0].getTime()<=e.endTimeRange}))},e.prototype.push=function(e){this.positions.length&&this.positions[this.positions.length-1][1]*e<0&&this.clear(),this.positions.push([new Date,e]),this.filterPositions()},e.prototype.getEndSpeed=function(){if(this.filterPositions(),0===this.positions.length||1===this.positions.length)return 0;var e=this.positions[0],t=this.positions[this.positions.length-1];return(t[1]-e[1])/((t[0].getTime()-e[0].getTime())/1e3)},e.prototype.clear=function(){this.positions=[]},e}(),a=function(e){function t(t,n,o,i,r){void 0===t&&(t=200),void 0===n&&(n=1/0),void 0===o&&(o=1/0),void 0===i&&(i=1/0),void 0===r&&(r=1/0);var s=e.call(this)||this;return s.xDecelerationPerSecond=n,s.yDecelerationPerSecond=o,s.xMaxSpeed=i,s.yMaxSpeed=r,s.xPositionStore=new l(t),s.yPositionStore=new l(t),s}return i(t,e),t.prototype.setEndTimeRange=function(e){this.xPositionStore.endTimeRange=e,this.yPositionStore.endTimeRange=e},t.prototype.setXDecelerationPerSecond=function(e){this.xDecelerationPerSecond=e},t.prototype.setYDecelerationPerSecond=function(e){this.yDecelerationPerSecond=e},t.prototype.setXMaxSpeed=function(e){this.xMaxSpeed=e},t.prototype.setYMaxSpeed=function(e){this.yMaxSpeed=e},t.prototype.push=function(e,t){this.xPositionStore.push(e),this.yPositionStore.push(t)},t.prototype.end=function(){var e=this;this.timer&&window.clearInterval(this.timer);var t=this.dealOriginalSpeed(this.xPositionStore.getEndSpeed(),this.xMaxSpeed),n=this.dealOriginalSpeed(this.yPositionStore.getEndSpeed(),this.yMaxSpeed),o=0===s(t)?0:s(t)*this.xDecelerationPerSecond,i=0===s(n)?0:s(n)*this.yDecelerationPerSecond,r=t,l=n,a=Date.now();this.timer=setInterval((function(){var s=(Date.now()-a)/1e3;0!==s&&(r-=s*o,l-=s*i,a=Date.now(),r*t>0||l*n>0?((isNaN(r*t)||r*t<0)&&(r=0),(isNaN(r*n)||l*n<0)&&(l=0),e.emit("inertiaMove",{xSpeed:r,ySpeed:l,xDistance:r*s,yDistance:l*s})):e.stop())}))},t.prototype.stop=function(){this.xPositionStore.clear(),this.yPositionStore.clear(),window.clearInterval(this.timer),this.timer=null},t.prototype.dealOriginalSpeed=function(e,t){return Math.abs(e)>t?s(e)*t:e},t}(r.EventEmitter);t.EndInertiaUtil=a}])}));
{
"name": "scroll-sensor",
"version": "0.1.0",
"version": "0.1.1",
"description": "Scroll Sensor simulate scroll bar on a not scrollable dom.It has features of mouse wheel, mouse down move, touch move and scroll inertia.",

@@ -32,4 +32,5 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.9.5",
"@babel/preset-typescript": "^7.3.3",

@@ -41,3 +42,3 @@ "@typescript-eslint/eslint-plugin": "^1.13.0",

"eslint-loader": "^2.2.1",
"typescript": "^3.5.3",
"typescript": "=3.5.3",
"webpack": "^4.36.1",

@@ -49,4 +50,5 @@ "webpack-cli": "^3.3.6",

"@types/events": "^3.0.0",
"events": "^3.0.0"
"events": "^3.0.0",
"ts-loader": "^7.0.1"
}
}
{
"compilerOptions": {
"checkJs": true,
"allowJs": true,
"lib": ["es2018", "dom", "scripthost"],
"target": "es5"
}
},
"include": ["./src/*"],
"exclude": ["./node_modules"]
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc