Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swiperia-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swiperia-js - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

index.cjs

144

index.js

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

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=(s,t)=>{const[e,n]=s,[i,o]=t,r=i-e,c=o-n,a=Math.abs(r),d=Math.abs(c);return a===0&&d===0?null:a>d?r>0?"right":"left":c>0?"down":"up"},_=(s,t)=>{const[e,n]=s,[i,o]=t,r=e-i,c=n-o;return Math.sqrt(r*r+c*c)},m=(s,t,e)=>{if(e<0)throw new Error("Time delta must be positive.");if(e===0)return[1/0,1/0];const[n,i]=s,[o,r]=t,c=o-n,a=r-i;return[c/e,a/e]},u=(s,t,e)=>{if(e<0)throw new Error("Time delta must be positive.");return e===0?1/0:_(s,t)/e},l=(s,t,e)=>{const n=t[0]-s[0],i=t[1]-s[1],o=Math.abs(n),r=Math.abs(i);return{source:s,target:t,deltaX:n,deltaY:i,absX:o,absY:r,direction:v(s,t),velocity:u(s,t,e),vxvy:m(s,t,e),distance:_(s,t)}};class h{constructor(t,e){this.el=t,this._source=[0,0],this._startTime=0,this._callback=()=>{},this._config={threshold:10,allowedTime:300},e&&(this._config={...this._config,...e}),this._start=this._start.bind(this),this._move=this._move.bind(this),this._end=this._end.bind(this)}_start(t){const e=this.point(t);this._source=e,this._startTime=t.timeStamp,this._callback({event:t,type:"start",direction:null,source:e,target:e,deltaX:0,deltaY:0,absX:0,absY:0,velocity:0,vxvy:[0,0],distance:0})}_move(t){const e=this._source,n=this.point(t),i=t.timeStamp-this._startTime;this._callback({event:t,type:"move",...l(e,n,i)})}_end(t){const e=this._source,n=this.point(t),i=t.timeStamp-this._startTime,o=l(e,n,i),r=this._config.allowedTime,c=this._config.threshold;i<=r&&o.distance>=c?this._callback({event:t,type:"end",...o}):this._callback({event:t,type:"cancel",...o})}}class w extends h{constructor(t,e){super(t,e)}point(t){return[t.pageX,t.pageY]}_start(t){super._start(t),window.addEventListener("mousemove",this._move,!1),window.addEventListener("mouseup",this._end,!1)}_end(t){super._end(t),window.removeEventListener("mousemove",this._move,!1),window.removeEventListener("mouseup",this._end,!1)}listen(t){this._callback=t,this.el.addEventListener("mousedown",this._start,!1)}destroy(){this.el.removeEventListener("mousedown",this._start,!1),window.removeEventListener("mousemove",this._move,!1),window.removeEventListener("mouseup",this._end,!1)}}class f extends h{constructor(t,e){super(t,e)}point(t){const e=t.changedTouches[0];return[e.pageX,e.pageY]}_start(t){super._start(t),window.addEventListener("touchmove",this._move,!1),window.addEventListener("touchend",this._end,!1)}_end(t){super._end(t),window.removeEventListener("touchmove",this._move,!1),window.removeEventListener("touchend",this._end,!1)}listen(t){this._callback=t,this.el.addEventListener("touchstart",this._start,!1)}destroy(){this.el.removeEventListener("touchstart",this._start,!1),window.removeEventListener("touchmove",this._move,!1),window.removeEventListener("touchend",this._end,!1)}}class p{constructor(t,e,n){this.el=t,this.detectors=e,this.config=n,this._detectors=[]}listen(t){for(let e of this.detectors){const n=new e(this.el,this.config);this._detectors.push(n),n.listen(t)}}destroy(){for(let t of this._detectors)t.destroy()}}exports.AbstractSwiper=h;exports.MouseSwiper=w;exports.Swiper=p;exports.TouchSwiper=f;
const v = (s, t) => {
const [e, n] = s, [i, o] = t, r = i - e, c = o - n, a = Math.abs(r), h = Math.abs(c);
return a === 0 && h === 0 ? null : a > h ? r > 0 ? "right" : "left" : c > 0 ? "down" : "up";
}, l = (s, t) => {
const [e, n] = s, [i, o] = t, r = e - i, c = n - o;
return Math.sqrt(r * r + c * c);
}, m = (s, t, e) => {
if (e < 0)
throw new Error("Time delta must be positive.");
if (e === 0)
return [1 / 0, 1 / 0];
const [n, i] = s, [o, r] = t, c = o - n, a = r - i;
return [c / e, a / e];
}, u = (s, t, e) => {
if (e < 0)
throw new Error("Time delta must be positive.");
return e === 0 ? 1 / 0 : l(s, t) / e;
}, d = (s, t, e) => {
const n = t[0] - s[0], i = t[1] - s[1], o = Math.abs(n), r = Math.abs(i);
return {
source: s,
target: t,
deltaX: n,
deltaY: i,
absX: o,
absY: r,
direction: v(s, t),
velocity: u(s, t, e),
vxvy: m(s, t, e),
distance: l(s, t)
};
};
class _ {
constructor(t, e) {
this.el = t, this._source = [0, 0], this._startTime = 0, this._callback = () => {
}, this._config = {
threshold: 10,
allowedTime: 300
}, e && (this._config = {
...this._config,
...e
}), this._start = this._start.bind(this), this._move = this._move.bind(this), this._end = this._end.bind(this);
}
_start(t) {
const e = this.point(t);
this._source = e, this._startTime = t.timeStamp, this._callback({
event: t,
type: "start",
direction: null,
source: e,
target: e,
deltaX: 0,
deltaY: 0,
absX: 0,
absY: 0,
velocity: 0,
vxvy: [0, 0],
distance: 0
});
}
_move(t) {
const e = this._source, n = this.point(t), i = t.timeStamp - this._startTime;
this._callback({
event: t,
type: "move",
...d(e, n, i)
});
}
_end(t) {
const e = this._source, n = this.point(t), i = t.timeStamp - this._startTime, o = d(e, n, i), r = this._config.allowedTime, c = this._config.threshold;
i <= r && o.distance >= c ? this._callback({
event: t,
type: "end",
...o
}) : this._callback({
event: t,
type: "cancel",
...o
});
}
}
class w extends _ {
constructor(t, e) {
super(t, e);
}
point(t) {
return [t.pageX, t.pageY];
}
_start(t) {
super._start(t), window.addEventListener("mousemove", this._move, !1), window.addEventListener("mouseup", this._end, !1);
}
_end(t) {
super._end(t), window.removeEventListener("mousemove", this._move, !1), window.removeEventListener("mouseup", this._end, !1);
}
listen(t) {
this._callback = t, this.el.addEventListener("mousedown", this._start, !1);
}
destroy() {
this.el.removeEventListener("mousedown", this._start, !1), window.removeEventListener("mousemove", this._move, !1), window.removeEventListener("mouseup", this._end, !1);
}
}
class f extends _ {
constructor(t, e) {
super(t, e);
}
point(t) {
const e = t.changedTouches[0];
return [e.pageX, e.pageY];
}
_start(t) {
super._start(t), window.addEventListener("touchmove", this._move, !1), window.addEventListener("touchend", this._end, !1);
}
_end(t) {
super._end(t), window.removeEventListener("touchmove", this._move, !1), window.removeEventListener("touchend", this._end, !1);
}
listen(t) {
this._callback = t, this.el.addEventListener("touchstart", this._start, !1);
}
destroy() {
this.el.removeEventListener("touchstart", this._start, !1), window.removeEventListener("touchmove", this._move, !1), window.removeEventListener("touchend", this._end, !1);
}
}
class p {
constructor(t, e, n) {
this.el = t, this.detectors = e, this.config = n, this._detectors = [];
}
listen(t) {
for (let e of this.detectors) {
const n = new e(this.el, this.config);
this._detectors.push(n), n.listen(t);
}
}
destroy() {
for (let t of this._detectors)
t.destroy();
}
}
export {
_ as AbstractSwiper,
w as MouseSwiper,
p as Swiper,
f as TouchSwiper
};

3

package.json
{
"name": "swiperia-js",
"version": "1.0.1",
"version": "1.0.2",
"type": "module",
"description": "Swiperia JS: A powerful suite of JavaScript libraries for building intuitive swipe-driven user interfaces. Provides core gesture handling, web-specific implementations, and React components for seamless integration.",

@@ -5,0 +6,0 @@ "license": "MIT",

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