New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@any-scroll/core

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@any-scroll/core - npm Package Compare versions

Comparing version
0.6.1
to
0.6.2
+184
-218
dist/index.es.js

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

import { __extends, __assign, __read, __spreadArray, __values } from 'tslib';
import AnyTouch from '@any-touch/core';

@@ -11,62 +10,60 @@ import pan from '@any-touch/pan';

var SCROLL_END_DELAY = 16;
var TYPE_BEFORE_DESTROY = 'beforeDestroy';
var TYPE_BEFORE_UPDATED = 'beforeUpdate';
var TYPE_UPDATED = 'updated';
var TYPE_SCROLL = 'scroll';
var TYPE_SCROLL_END = 'scrollEnd';
const SCROLL_END_DELAY = 16;
const TYPE_BEFORE_DESTROY = 'beforeDestroy';
const TYPE_BEFORE_UPDATED = 'beforeUpdate';
const TYPE_UPDATED = 'updated';
const TYPE_SCROLL = 'scroll';
const TYPE_SCROLL_END = 'scrollEnd';
var ResizeObserver$1 = window.ResizeObserver, MutationObserver = window.MutationObserver;
var Content$1 = (function (_super) {
__extends(Content, _super);
function Content(contentEl, wrapRef) {
var _this = _super.call(this) || this;
_this.xy = [0, 0];
_this.minXY = [0, 0];
_this.maxXY = [0, 0];
_this.wrapSize = [0, 0];
_this.contentSize = [0, 0];
_this.targets = [];
_this.isScrolling = false;
_this.__scrollEndTimeId = -1;
_this.__dampScrollRafId = -1;
_this.__stopScroll = function () { };
_this.el = contentEl;
_this.wrapRef = wrapRef;
var options = wrapRef.options;
_this.__options = options;
wrapRef.on(TYPE_BEFORE_UPDATED, function () {
_this.update();
const { ResizeObserver: ResizeObserver$1, MutationObserver } = window;
class Content$1 extends AnyEvent {
constructor(contentEl, wrapRef) {
super();
this.xy = [0, 0];
this.minXY = [0, 0];
this.maxXY = [0, 0];
this.wrapSize = [0, 0];
this.contentSize = [0, 0];
this.targets = [];
this.isScrolling = false;
this.__scrollEndTimeId = -1;
this.__dampScrollRafId = -1;
this.__stopScroll = () => { };
this.el = contentEl;
this.wrapRef = wrapRef;
const { options } = wrapRef;
this.__options = options;
wrapRef.on(TYPE_BEFORE_UPDATED, () => {
this.update();
});
if (ResizeObserver$1) {
var ro_1 = new ResizeObserver$1(function () {
_this.update();
const ro = new ResizeObserver$1(() => {
this.update();
});
ro_1.observe(contentEl);
_this.on(TYPE_BEFORE_DESTROY, function () {
ro_1.disconnect();
ro.observe(contentEl);
this.on(TYPE_BEFORE_DESTROY, () => {
ro.disconnect();
});
}
else if (MutationObserver) {
_this.update();
var observer_1 = new MutationObserver(function () {
_this.update();
this.update();
const observer = new MutationObserver(() => {
this.update();
});
observer_1.observe(contentEl, {
observer.observe(contentEl, {
childList: true,
subtree: true,
});
_this.on(TYPE_BEFORE_DESTROY, function () {
observer_1.disconnect();
this.on(TYPE_BEFORE_DESTROY, () => {
observer.disconnect();
});
}
return _this;
}
Content.prototype.set = function (options) {
this.__options = __assign(__assign({}, this.__options), options);
set(options) {
this.__options = Object.assign(Object.assign({}, this.__options), options);
this.update();
};
Content.prototype.update = function () {
var el = this.el;
var offsetWidth = el.offsetWidth, offsetHeight = el.offsetHeight, clientWidth = el.clientWidth, clientHeight = el.clientHeight, scrollWidth = el.scrollWidth, scrollHeight = el.scrollHeight;
}
update() {
const { el } = this;
const { offsetWidth, offsetHeight, clientWidth, clientHeight, scrollWidth, scrollHeight } = el;
this.wrapSize = [this.wrapRef.size[0], this.wrapRef.size[1]];

@@ -82,6 +79,5 @@ this.contentSize = [offsetWidth - clientWidth + scrollWidth, offsetHeight - clientHeight + scrollHeight];

this.emit(TYPE_UPDATED, this);
};
Content.prototype.stop = function () {
var _this = this;
if (this.isScrolling && this.xy.every(function (v, i) { return inRange(v, _this.minXY[i], _this.maxXY[i]); })) {
}
stop() {
if (this.isScrolling && this.xy.every((v, i) => inRange(v, this.minXY[i], this.maxXY[i]))) {
this.emit(TYPE_SCROLL_END, this.xy);

@@ -92,79 +88,68 @@ }

this.__stopScroll();
};
Content.prototype.snap = function () {
var _this = this;
var xy = runTwice(function (i) { return clamp(_this.xy[i], _this.minXY[i], _this.maxXY[i]); });
}
snap() {
const xy = runTwice((i) => clamp(this.xy[i], this.minXY[i], this.maxXY[i]));
this.dampScroll(xy);
};
Content.prototype.moveTo = function (distXY) {
var _this = this;
var _a = this.__options, allow = _a.allow, overflowDistance = _a.overflowDistance;
}
moveTo(distXY) {
const { allow, overflowDistance } = this.__options;
if (!allow.includes(true))
return this.xy;
clearTimeout(this.__scrollEndTimeId);
var tupleXY = xY2Tuple(distXY, this.xy);
var nextXY = runTwice(function (i) {
const tupleXY = xY2Tuple(distXY, this.xy);
const nextXY = runTwice((i) => {
if (allow[i] && void 0 !== tupleXY[i]) {
return clamp(tupleXY[i], _this.minXY[i] - overflowDistance, _this.maxXY[i] + overflowDistance);
return clamp(tupleXY[i], this.minXY[i] - overflowDistance, this.maxXY[i] + overflowDistance);
}
return _this.xy[i];
return this.xy[i];
});
var isChanged = this.xy.some(function (xOrY, i) { return xOrY !== nextXY[i]; });
const isChanged = this.xy.some((xOrY, i) => xOrY !== nextXY[i]);
if (!isChanged)
return this.xy;
runTwice(function (i) { return (_this.xy[i] = nextXY[i]); });
var _b = __read(this.xy, 2), x = _b[0], y = _b[1];
var targets = this.targets;
var target = targets[0];
this.emit('scroll', { targets: targets, target: target, x: x, y: y });
runTwice((i) => (this.xy[i] = nextXY[i]));
const [x, y] = this.xy;
const { targets } = this;
const target = targets[0];
this.emit('scroll', { targets, target, x, y });
this.__options.render(this.el, [-this.xy[0], -this.xy[1]]);
return this.xy;
};
Content.prototype.scrollTo = function (distXY, duration, easing) {
var _this = this;
if (duration === void 0) { duration = 1000; }
var tupleXY = xY2Tuple(distXY, this.xy);
var overflowDistance = this.__options.overflowDistance;
}
scrollTo(distXY, duration = 1000, easing) {
const tupleXY = xY2Tuple(distXY, this.xy);
const { overflowDistance } = this.__options;
this.stop();
this.isScrolling = true;
var realDist = runTwice(function (i) {
return clamp(tupleXY[i], _this.minXY[i] - overflowDistance, _this.maxXY[i] + overflowDistance);
});
var _a = __read(tween(this.xy, realDist, duration, easing), 3), run = _a[0], stop = _a[1], done = _a[2];
const realDist = runTwice((i) => clamp(tupleXY[i], this.minXY[i] - overflowDistance, this.maxXY[i] + overflowDistance));
const [run, stop, done] = tween(this.xy, realDist, duration, easing);
run(this.moveTo.bind(this));
this.__stopScroll = stop;
done(function () {
_this.snap();
_this.isScrolling = false;
done(() => {
this.snap();
this.isScrolling = false;
});
};
Content.prototype.scrollToElement = function (el, offset, duration, easingFunction) {
var _this = this;
if (offset === void 0) { offset = [0, 0]; }
if (duration === void 0) { duration = 1000; }
if (easingFunction === void 0) { easingFunction = easing; }
}
scrollToElement(el, offset = [0, 0], duration = 1000, easingFunction = easing) {
if (!this.el.contains(el))
return;
var offsetTuple = xY2Tuple(offset, [0, 0]);
var rect = this.wrapRef.el.getBoundingClientRect();
var _a = el.getBoundingClientRect(), x = _a.x, y = _a.y;
var distXY = runTwice(function (i) { return _this.xy[i] + [x, y][i] - [rect.x, rect.y][i] + offsetTuple[i]; });
const offsetTuple = xY2Tuple(offset, [0, 0]);
const rect = this.wrapRef.el.getBoundingClientRect();
const { x, y } = el.getBoundingClientRect();
const distXY = runTwice(i => this.xy[i] + [x, y][i] - [rect.x, rect.y][i] + offsetTuple[i]);
this.scrollTo(distXY, duration, easingFunction);
};
Content.prototype.dampScroll = function (distXY, damping) {
var _this = this;
var tupleXY = xY2Tuple(distXY, this.xy);
var _a = this.__options, overflowDistance = _a.overflowDistance, allow = _a.allow;
var noScroll = runTwice(function (i) { return !allow[i] || tupleXY[i] === _this.xy[i]; }).every(function (isMoved) { return isMoved; });
}
dampScroll(distXY, damping) {
const tupleXY = xY2Tuple(distXY, this.xy);
const { overflowDistance, allow } = this.__options;
const noScroll = runTwice((i) => !allow[i] || tupleXY[i] === this.xy[i]).every((isMoved) => isMoved);
if (noScroll)
return;
raf.cancel(this.__dampScrollRafId);
var _distXY = __spreadArray([], __read(tupleXY), false);
const _distXY = [...tupleXY];
function _moveTo(context) {
context.isScrolling = true;
var xy = context.xy, minXY = context.minXY, maxXY = context.maxXY;
var _nextXY = runTwice(function (i) {
const { xy, minXY, maxXY } = context;
const _nextXY = runTwice((i) => {
if (!allow[i])
return xy[i];
var _nextValue = damp(context.xy[i], _distXY[i], damping);
const _nextValue = damp(context.xy[i], _distXY[i], damping);
if (_nextValue >= maxXY[i] + overflowDistance) {

@@ -190,5 +175,5 @@ _distXY[i] = maxXY[i];

context.moveTo(_nextXY);
var _needScroll = runTwice(function (i) { return allow[i] && _distXY[i] !== _nextXY[i]; }).some(function (bool) { return bool; });
const _needScroll = runTwice((i) => allow[i] && _distXY[i] !== _nextXY[i]).some((bool) => bool);
if (_needScroll) {
context.__dampScrollRafId = raf(function () {
context.__dampScrollRafId = raf(() => {
_moveTo(context);

@@ -203,119 +188,115 @@ });

_moveTo(this);
};
Content.prototype.destroy = function () {
_super.prototype.destroy.call(this);
};
return Content;
}(AnyEvent));
}
destroy() {
super.destroy();
}
}
var setTimeout = window.setTimeout, ResizeObserver = window.ResizeObserver;
var DEFAULT_OPTIONS = {
const { setTimeout, ResizeObserver } = window;
const DEFAULT_OPTIONS = {
overflowDistance: 100,
damping: 0.1,
allow: [true, true],
render: render,
render,
};
var Wrap$1 = (function (_super) {
__extends(Wrap, _super);
function Wrap(el, options) {
var _this = _super.call(this) || this;
_this.size = [0, 0];
_this.targets = [];
_this.__contentRefList = [];
_this.el = el;
_this.options = __assign(__assign({}, DEFAULT_OPTIONS), options);
class Wrap$1 extends AnyEvent {
constructor(el, options) {
super();
this.size = [0, 0];
this.targets = [];
this.__contentRefList = [];
this.el = el;
this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
setStyle(el, {
position: "relative",
position: `relative`,
overflow: 'hidden',
});
Array.from(el.children).forEach(function (contentEl) {
Array.from(el.children).forEach((contentEl) => {
if (contentEl.hasAttribute('no-scroll'))
return;
var contentRef = new Content$1(contentEl, _this);
contentRef.on(TYPE_SCROLL, function (arg) {
_this.emit(TYPE_SCROLL, arg);
const contentRef = new Content$1(contentEl, this);
contentRef.on(TYPE_SCROLL, (arg) => {
this.emit(TYPE_SCROLL, arg);
});
contentRef.on(TYPE_SCROLL_END, function (arg) {
_this.emit(TYPE_SCROLL_END, arg);
contentRef.on(TYPE_SCROLL_END, (arg) => {
this.emit(TYPE_SCROLL_END, arg);
});
contentRef.on(TYPE_UPDATED, function (arg) {
_this.emit(TYPE_UPDATED, arg);
contentRef.on(TYPE_UPDATED, arg => {
this.emit(TYPE_UPDATED, arg);
});
_this.on(TYPE_BEFORE_DESTROY, function () {
this.on(TYPE_BEFORE_DESTROY, () => {
contentRef.destroy();
});
_this.__contentRefList.push(contentRef);
this.__contentRefList.push(contentRef);
});
_this.__currentContentRef = _this.getContentRef();
this.__currentContentRef = this.getContentRef();
if (ResizeObserver) {
var ro_1 = new ResizeObserver(_this.update.bind(_this));
ro_1.observe(el);
_this.on(TYPE_BEFORE_DESTROY, function () {
ro_1.disconnect();
const ro = new ResizeObserver(this.update.bind(this));
ro.observe(el);
this.on(TYPE_BEFORE_DESTROY, () => {
ro.disconnect();
});
}
else {
_this.update();
this.update();
}
var at = new AnyTouch(el);
const at = new AnyTouch(el);
at.use(pan);
at.use(swipe);
_this.at = at;
at.on(['panstart', 'panmove'], function (e) {
var currentContentRef = _this.__currentContentRef;
this.at = at;
at.on(['panstart', 'panmove'], (e) => {
const { __currentContentRef: currentContentRef } = this;
if (null !== currentContentRef) {
_this.targets = e.targets;
var deltaX = e.deltaX, deltaY = e.deltaY;
var xy = currentContentRef.xy;
this.targets = e.targets;
const { deltaX, deltaY } = e;
const { xy } = currentContentRef;
currentContentRef.moveTo([xy[0] - deltaX, xy[1] - deltaY]);
}
});
at.on('panend', function (e) {
if (null === _this.__currentContentRef)
at.on('panend', (e) => {
if (null === this.__currentContentRef)
return;
_this.__currentContentRef.__scrollEndTimeId = setTimeout(function () {
if (null !== _this.__currentContentRef) {
_this.targets = e.targets;
_this.emit(TYPE_SCROLL_END, _this.__currentContentRef.xy);
this.__currentContentRef.__scrollEndTimeId = setTimeout(() => {
if (null !== this.__currentContentRef) {
this.targets = e.targets;
this.emit(TYPE_SCROLL_END, this.__currentContentRef.xy);
}
}, SCROLL_END_DELAY);
});
at.on('at:start', function (e) {
at.on('at:start', (e) => {
var _a;
_this.emit('at:start');
var targetEl = e.target;
_this.__currentContentRef = _this.getContentRef(targetEl);
(_a = _this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.stop();
this.emit('at:start');
const targetEl = e.target;
this.__currentContentRef = this.getContentRef(targetEl);
(_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.stop();
});
at.on('at:end', function () {
at.on('at:end', () => {
var _a;
_this.emit('at:end');
(_a = _this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.snap();
this.emit('at:end');
(_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.snap();
});
var swipeContext = at.get('swipe');
const swipeContext = at.get('swipe');
if (swipeContext) {
swipeContext.velocity = 1;
}
at.on('swipe', function (e) {
var currentContentRef = _this.__currentContentRef;
at.on('swipe', (e) => {
const { __currentContentRef: currentContentRef } = this;
if (null === currentContentRef)
return;
_this.targets = e.targets;
var deltaX = e.speedX * 200;
var deltaY = e.speedY * 200;
this.targets = e.targets;
const deltaX = e.speedX * 200;
const deltaY = e.speedY * 200;
currentContentRef.dampScroll([currentContentRef.xy[0] - deltaX, currentContentRef.xy[1] - deltaY]);
});
at.on('at:after', function (e) {
_this.emit(e.name, e);
at.on('at:after', e => {
this.emit(e.name, e);
});
return _this;
}
Wrap.prototype.update = function () {
var _a = this.el, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
update() {
const { clientWidth, clientHeight } = this.el;
this.size = [clientWidth, clientHeight];
this.emit(TYPE_BEFORE_UPDATED, this.size);
};
Wrap.prototype.getContentRef = function (elOrIndex) {
var e_1, _a;
var __contentRefList = this.__contentRefList;
}
getContentRef(elOrIndex) {
const { __contentRefList } = this;
if (void 0 === elOrIndex) {

@@ -328,67 +309,52 @@ return this.__currentContentRef || __contentRefList[__contentRefList.length - 1];

else {
try {
for (var __contentRefList_1 = __values(__contentRefList), __contentRefList_1_1 = __contentRefList_1.next(); !__contentRefList_1_1.done; __contentRefList_1_1 = __contentRefList_1.next()) {
var ref = __contentRefList_1_1.value;
if (ref.el.contains(elOrIndex)) {
return ref;
}
for (let ref of __contentRefList) {
if (ref.el.contains(elOrIndex)) {
return ref;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (__contentRefList_1_1 && !__contentRefList_1_1.done && (_a = __contentRefList_1.return)) _a.call(__contentRefList_1);
}
finally { if (e_1) throw e_1.error; }
}
return this.__currentContentRef;
}
};
Wrap.prototype.active = function (contentRef) {
}
active(contentRef) {
this.__currentContentRef = contentRef;
};
Wrap.prototype.moveTo = function (distXY) {
}
moveTo(distXY) {
var _a;
return (_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.moveTo(distXY);
};
Wrap.prototype.scrollTo = function (distXY, duration, easing) {
}
scrollTo(distXY, duration = 1000, easing) {
var _a;
if (duration === void 0) { duration = 1000; }
(_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.scrollTo(distXY, duration, easing);
};
Wrap.prototype.scrollToElement = function (el, offset, duration, easing) {
}
scrollToElement(el, offset, duration, easing) {
var _a;
(_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.scrollToElement(el, offset, duration, easing);
};
Wrap.prototype.dampScroll = function (distXY, damping) {
}
dampScroll(distXY, damping = this.options.damping) {
var _a;
if (damping === void 0) { damping = this.options.damping; }
(_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.dampScroll(distXY, damping);
};
Wrap.prototype.stop = function () {
}
stop() {
var _a;
(_a = this.__currentContentRef) === null || _a === void 0 ? void 0 : _a.stop();
};
Wrap.prototype.destroy = function () {
}
destroy() {
this.emit(TYPE_BEFORE_DESTROY);
this.at.destroy();
_super.prototype.destroy.call(this);
};
return Wrap;
}(AnyEvent));
super.destroy();
}
}
var Wrap = Wrap$1;
var Content = Content$1;
var default_1 = (function (_super) {
__extends(default_1, _super);
function default_1(el, options) {
return _super.call(this, el, options) || this;
const Wrap = Wrap$1;
const Content = Content$1;
class index extends Wrap {
constructor(el, options) {
super(el, options);
}
default_1.prototype.use = function (plugin, options) {
use(plugin, options) {
plugin(this, options);
};
return default_1;
}(Wrap));
}
}
export { Content, Wrap, default_1 as default };
export { Content, Wrap, index as default };
//# sourceMappingURL=index.es.js.map
{
"name": "@any-scroll/core",
"version": "0.6.1",
"version": "0.6.2",
"description": "虚拟滚动",

@@ -49,3 +49,3 @@ "unpkg": "dist/any-scroll.js",

"sideEffects": false,
"gitHead": "ab245ce8e948f8a977b767f632b5921bf101e2de"
"gitHead": "b972397294cbe4e1edb694c63bac4a74f5e3aaf3"
}

Sorry, the diff of this file is not supported yet