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

oribella-swipe

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oribella-swipe - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

12

CHANGELOG.md

@@ -0,3 +1,13 @@

<a name="0.4.1"></a>
## 0.4.1 (2016-03-04)
### Bug Fixes
* **dist:** update corrupt dist ([051784f](https://github.com/oribella/swipe/commit/051784f))
<a name="0.4.0"></a>
# 0.4.0 (2016-02-22)
# [0.4.0](https://github.com/oribella/swipe/compare/bf3d836...v0.4.0) (2016-02-22)

@@ -4,0 +14,0 @@

110

dist/amd/index.js

@@ -1,20 +0,28 @@

"use strict";
define(["exports", "oribella-framework", "./swipe-data"], function (exports, _oribellaFramework, _swipeData) {
"use strict";
define(["exports", "oribella-framework", "./swipe-data"], function (exports, _oribellaFramework, _swipeData) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Swipe = undefined;
class Swipe {
static defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
constructor(subscriber, element) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Swipe = (function () {
_createClass(Swipe, null, [{
key: "defaultOptions",
value: function defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
}]);
function Swipe(subscriber, element) {
_classCallCheck(this, Swipe);
this.subscriber = subscriber;

@@ -29,44 +37,48 @@ this.element = element;

start(event, pointers) {
this.data.pointers = pointers;
this.startPoint = pointers[0].page;
this.swipeData.addObservation(this.startPoint);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
update(event, pointers) {
this.data.pointers = pointers;
const currentPoint = pointers[0].page;
if (currentPoint.distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
_createClass(Swipe, [{
key: "start",
value: function start(event, pointers) {
this.data.pointers = pointers;
this.startPoint = pointers[0].page;
this.swipeData.addObservation(this.startPoint);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
this.swipeData.addObservation(currentPoint);
if (!this[_oribellaFramework.GESTURE_STARTED]) {
this.result = this.subscriber.start(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result) + _oribellaFramework.RETURN_FLAG.STARTED;
} else {
this.result = this.subscriber.update(event, this.data, this.element);
}, {
key: "update",
value: function update(event, pointers) {
this.data.pointers = pointers;
var currentPoint = pointers[0].page;
if (currentPoint.distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
}
this.swipeData.addObservation(currentPoint);
if (!this[_oribellaFramework.GESTURE_STARTED]) {
this.result = this.subscriber.start(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result) + _oribellaFramework.RETURN_FLAG.STARTED;
} else {
this.result = this.subscriber.update(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
}
}, {
key: "end",
value: function end(event, pointers) {
this.data.pointers = pointers;
this.swipeData.addObservation(pointers[0].page);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
}
}, {
key: "cancel",
value: function cancel(event, pointers) {
this.data.pointers = pointers;
this.subscriber.cancel(event, this.data, this.element);
}
}]);
end(event, pointers) {
this.data.pointers = pointers;
this.swipeData.addObservation(pointers[0].page);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
return Swipe;
})();
cancel(event, pointers) {
this.data.pointers = pointers;
this.subscriber.cancel(event, this.data, this.element);
}
}
exports.Swipe = Swipe;
});

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

"use strict";
define(["exports"], function (exports) {
"use strict";
define(["exports"], function (exports) {
Object.defineProperty(exports, "__esModule", {

@@ -8,4 +8,10 @@ value: true

class SwipeData {
constructor(maxObservations) {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SwipeData = (function () {
function SwipeData(maxObservations) {
_classCallCheck(this, SwipeData);
this.maxObservations = maxObservations;

@@ -15,45 +21,49 @@ this.timeSeries = [];

addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
_createClass(SwipeData, [{
key: "addObservation",
value: function addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
}
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
}, {
key: "getVelocity",
value: function getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
if (this.timeSeries.length < 2) {
return 0;
if (this.timeSeries.length < 2) {
return 0;
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[0];
dist = o1.point.distanceTo(o2.point);
elapsed = o1.timeStamp - o2.timeStamp;
v = 1000 * dist / (1 + elapsed); //pixels per second
return 0.8 * v + 0.2 * velocity;
}
}, {
key: "getDelta",
value: function getDelta() {
var o1, o2, dx, dy;
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[0];
dist = o1.point.distanceTo(o2.point);
elapsed = o1.timeStamp - o2.timeStamp;
v = 1000 * dist / (1 + elapsed);
return 0.8 * v + 0.2 * velocity;
}
if (this.timeSeries.length < 2) {
return [0, 0];
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
getDelta() {
var o1, o2, dx, dy;
if (this.timeSeries.length < 2) {
return [0, 0];
return [dx, dy];
}
}]);
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
return [dx, dy];
}
return SwipeData;
})();
}
exports.SwipeData = SwipeData;
});

@@ -6,4 +6,7 @@ "use strict";

});
exports.Swipe = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _oribellaFramework = require("oribella-framework");

@@ -13,12 +16,18 @@

class Swipe {
static defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
constructor(subscriber, element) {
var Swipe = (function () {
_createClass(Swipe, null, [{
key: "defaultOptions",
value: function defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
}]);
function Swipe(subscriber, element) {
_classCallCheck(this, Swipe);
this.subscriber = subscriber;

@@ -32,35 +41,48 @@ this.element = element;

}
start(event, pointers) {
this.data.pointers = pointers;
this.startPoint = pointers[0].page;
this.swipeData.addObservation(this.startPoint);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
update(event, pointers) {
this.data.pointers = pointers;
const currentPoint = pointers[0].page;
if (currentPoint.distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
_createClass(Swipe, [{
key: "start",
value: function start(event, pointers) {
this.data.pointers = pointers;
this.startPoint = pointers[0].page;
this.swipeData.addObservation(this.startPoint);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
this.swipeData.addObservation(currentPoint);
if (!this[_oribellaFramework.GESTURE_STARTED]) {
this.result = this.subscriber.start(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result) + _oribellaFramework.RETURN_FLAG.STARTED;
} else {
this.result = this.subscriber.update(event, this.data, this.element);
}, {
key: "update",
value: function update(event, pointers) {
this.data.pointers = pointers;
var currentPoint = pointers[0].page;
if (currentPoint.distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
}
this.swipeData.addObservation(currentPoint);
if (!this[_oribellaFramework.GESTURE_STARTED]) {
this.result = this.subscriber.start(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result) + _oribellaFramework.RETURN_FLAG.STARTED;
} else {
this.result = this.subscriber.update(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
}
}, {
key: "end",
value: function end(event, pointers) {
this.data.pointers = pointers;
this.swipeData.addObservation(pointers[0].page);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
}
end(event, pointers) {
this.data.pointers = pointers;
this.swipeData.addObservation(pointers[0].page);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
cancel(event, pointers) {
this.data.pointers = pointers;
this.subscriber.cancel(event, this.data, this.element);
}
}
}, {
key: "cancel",
value: function cancel(event, pointers) {
this.data.pointers = pointers;
this.subscriber.cancel(event, this.data, this.element);
}
}]);
return Swipe;
})();
exports.Swipe = Swipe;

@@ -6,43 +6,61 @@ "use strict";

});
class SwipeData {
constructor(maxObservations) {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SwipeData = (function () {
function SwipeData(maxObservations) {
_classCallCheck(this, SwipeData);
this.maxObservations = maxObservations;
this.timeSeries = [];
}
addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
_createClass(SwipeData, [{
key: "addObservation",
value: function addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
}
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
}, {
key: "getVelocity",
value: function getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
if (this.timeSeries.length < 2) {
return 0;
if (this.timeSeries.length < 2) {
return 0;
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[0];
dist = o1.point.distanceTo(o2.point);
elapsed = o1.timeStamp - o2.timeStamp;
v = 1000 * dist / (1 + elapsed); //pixels per second
return 0.8 * v + 0.2 * velocity;
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[0];
dist = o1.point.distanceTo(o2.point);
elapsed = o1.timeStamp - o2.timeStamp;
v = 1000 * dist / (1 + elapsed); //pixels per second
return 0.8 * v + 0.2 * velocity;
}
getDelta() {
var o1, o2, dx, dy;
}, {
key: "getDelta",
value: function getDelta() {
var o1, o2, dx, dy;
if (this.timeSeries.length < 2) {
return [0, 0];
if (this.timeSeries.length < 2) {
return [0, 0];
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
return [dx, dy];
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
}]);
return [dx, dy];
}
}
return SwipeData;
})();
exports.SwipeData = SwipeData;

@@ -1,5 +0,10 @@

"use strict";
System.register(["oribella-framework", "./swipe-data"], function (_export) {
"use strict";
System.register(["oribella-framework", "./swipe-data"], function (_export) {
var RETURN_FLAG, GESTURE_STARTED, SwipeData;
var RETURN_FLAG, GESTURE_STARTED, SwipeData, Swipe;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {

@@ -13,13 +18,18 @@ setters: [function (_oribellaFramework) {

execute: function () {
class Swipe {
static defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
Swipe = (function () {
_createClass(Swipe, null, [{
key: "defaultOptions",
value: function defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
}]);
constructor(subscriber, element) {
function Swipe(subscriber, element) {
_classCallCheck(this, Swipe);
this.subscriber = subscriber;

@@ -34,43 +44,47 @@ this.element = element;

start(event, pointers) {
this.data.pointers = pointers;
this.startPoint = pointers[0].page;
this.swipeData.addObservation(this.startPoint);
this.result = this.subscriber.down(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
update(event, pointers) {
this.data.pointers = pointers;
const currentPoint = pointers[0].page;
if (currentPoint.distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
_createClass(Swipe, [{
key: "start",
value: function start(event, pointers) {
this.data.pointers = pointers;
this.startPoint = pointers[0].page;
this.swipeData.addObservation(this.startPoint);
this.result = this.subscriber.down(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
this.swipeData.addObservation(currentPoint);
if (!this[GESTURE_STARTED]) {
this.result = this.subscriber.start(event, this.data, this.element);
return RETURN_FLAG.map(this.result) + RETURN_FLAG.STARTED;
} else {
this.result = this.subscriber.update(event, this.data, this.element);
}, {
key: "update",
value: function update(event, pointers) {
this.data.pointers = pointers;
var currentPoint = pointers[0].page;
if (currentPoint.distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
}
this.swipeData.addObservation(currentPoint);
if (!this[GESTURE_STARTED]) {
this.result = this.subscriber.start(event, this.data, this.element);
return RETURN_FLAG.map(this.result) + RETURN_FLAG.STARTED;
} else {
this.result = this.subscriber.update(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
}
}, {
key: "end",
value: function end(event, pointers) {
this.data.pointers = pointers;
this.swipeData.addObservation(pointers[0].page);
this.result = this.subscriber.end(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
}
}, {
key: "cancel",
value: function cancel(event, pointers) {
this.data.pointers = pointers;
this.subscriber.cancel(event, this.data, this.element);
}
}]);
end(event, pointers) {
this.data.pointers = pointers;
this.swipeData.addObservation(pointers[0].page);
this.result = this.subscriber.end(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
return Swipe;
})();
cancel(event, pointers) {
this.data.pointers = pointers;
this.subscriber.cancel(event, this.data, this.element);
}
}
_export("Swipe", Swipe);

@@ -77,0 +91,0 @@ }

@@ -1,9 +0,17 @@

"use strict";
System.register([], function (_export) {
"use strict";
System.register([], function (_export) {
var SwipeData;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
return {
setters: [],
execute: function () {
class SwipeData {
constructor(maxObservations) {
SwipeData = (function () {
function SwipeData(maxObservations) {
_classCallCheck(this, SwipeData);
this.maxObservations = maxObservations;

@@ -13,44 +21,48 @@ this.timeSeries = [];

addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
_createClass(SwipeData, [{
key: "addObservation",
value: function addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
}
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
}, {
key: "getVelocity",
value: function getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
if (this.timeSeries.length < 2) {
return 0;
if (this.timeSeries.length < 2) {
return 0;
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[0];
dist = o1.point.distanceTo(o2.point);
elapsed = o1.timeStamp - o2.timeStamp;
v = 1000 * dist / (1 + elapsed); //pixels per second
return 0.8 * v + 0.2 * velocity;
}
}, {
key: "getDelta",
value: function getDelta() {
var o1, o2, dx, dy;
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[0];
dist = o1.point.distanceTo(o2.point);
elapsed = o1.timeStamp - o2.timeStamp;
v = 1000 * dist / (1 + elapsed);
return 0.8 * v + 0.2 * velocity;
}
if (this.timeSeries.length < 2) {
return [0, 0];
}
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
getDelta() {
var o1, o2, dx, dy;
if (this.timeSeries.length < 2) {
return [0, 0];
return [dx, dy];
}
}]);
o1 = this.timeSeries[this.timeSeries.length - 1];
o2 = this.timeSeries[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
return [dx, dy];
}
return SwipeData;
})();
}
_export("SwipeData", SwipeData);

@@ -57,0 +69,0 @@ }

{
"name": "oribella-swipe",
"version": "0.4.0",
"version": "0.4.1",
"description": "Swipe gesture",

@@ -5,0 +5,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