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.3.4 to 0.3.5

10

CHANGELOG.md

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

<a name="0.3.5"></a>
## [0.3.5](https://github.com/oribella/swipe/compare/v0.3.4...v0.3.5) (2015-12-11)
### Bug Fixes
* **dist:** use `es2015`, `stage-1` and `stage-2` ([2aab480](https://github.com/oribella/swipe/commit/2aab480))
<a name="0.3.4"></a>

@@ -2,0 +12,0 @@ ## [0.3.4](https://github.com/oribella/swipe/compare/v0.3.3...v0.3.4) (2015-12-11)

2

config.js

@@ -19,3 +19,3 @@ System.config({

"core-js": "npm:core-js@1.2.6",
"oribella-framework": "npm:oribella-framework@0.3.0",
"oribella-framework": "npm:oribella-framework@0.3.4",
"github:jspm/nodelibs-assert@0.1.0": {

@@ -22,0 +22,0 @@ "assert": "npm:assert@1.3.0"

@@ -9,13 +9,42 @@ "use strict";

class Swipe {
static defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
constructor(subscriber, element) {
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;
};
})();
var Swipe = exports.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;

@@ -30,43 +59,45 @@ this.element = element;

start(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.startPoint = pagePoints[0];
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
update(event, pagePoints) {
this.data.pagePoints = pagePoints;
if (pagePoints[0].distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
_createClass(Swipe, [{
key: "start",
value: function start(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.startPoint = pagePoints[0];
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
this.swipeData.addObservation(pagePoints[0]);
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, pagePoints) {
this.data.pagePoints = pagePoints;
if (pagePoints[0].distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
}
this.swipeData.addObservation(pagePoints[0]);
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, pagePoints) {
this.data.pagePoints = pagePoints;
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
}
}, {
key: "cancel",
value: function cancel(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.subscriber.cancel(event, this.data, this.element);
}
}]);
end(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
cancel(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.subscriber.cancel(event, this.data, this.element);
}
}
exports.Swipe = Swipe;
return Swipe;
})();
});

@@ -8,51 +8,79 @@ "use strict";

class SwipeData {
constructor(maxObservations) {
this.maxObservations = maxObservations;
this.timeSeries = [];
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
addObservation(p) {
if (this.timeSeries.length === this.maxObservations) {
this.timeSeries.shift();
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);
}
this.timeSeries.push({
timeStamp: +new Date(),
point: p
});
}
getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
if (this.timeSeries.length < 2) {
return 0;
}
var SwipeData = exports.SwipeData = (function () {
function SwipeData(maxObservations) {
_classCallCheck(this, SwipeData);
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;
this.maxObservations = maxObservations;
this.timeSeries = [];
}
getDelta() {
var o1, o2, dx, dy;
_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;
if (this.timeSeries.length < 2) {
return [0, 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[this.timeSeries.length - 2];
dx = o1.point.x - o2.point.x;
dy = o1.point.y - o2.point.y;
return [dx, dy];
}
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];
}
}]);
exports.SwipeData = SwipeData;
return SwipeData;
})();
});
"use strict";
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; }; })();
Object.defineProperty(exports, "__esModule", {

@@ -12,12 +14,20 @@ value: true

class Swipe {
static defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
}
constructor(subscriber, element) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Swipe = exports.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;

@@ -31,34 +41,45 @@ this.element = element;

}
start(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.startPoint = pagePoints[0];
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
update(event, pagePoints) {
this.data.pagePoints = pagePoints;
if (pagePoints[0].distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
_createClass(Swipe, [{
key: "start",
value: function start(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.startPoint = pagePoints[0];
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.down(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
this.swipeData.addObservation(pagePoints[0]);
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, pagePoints) {
this.data.pagePoints = pagePoints;
if (pagePoints[0].distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
}
this.swipeData.addObservation(pagePoints[0]);
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, pagePoints) {
this.data.pagePoints = pagePoints;
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
}
end(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.end(event, this.data, this.element);
return _oribellaFramework.RETURN_FLAG.map(this.result);
}
cancel(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.subscriber.cancel(event, this.data, this.element);
}
}
exports.Swipe = Swipe;
}, {
key: "cancel",
value: function cancel(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.subscriber.cancel(event, this.data, this.element);
}
}]);
return Swipe;
})();
"use strict";
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; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
class SwipeData {
constructor(maxObservations) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SwipeData = exports.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];
}
}
exports.SwipeData = SwipeData;
return SwipeData;
})();
"use strict";
System.register(["oribella-framework", "./swipe-data"], function (_export) {
var RETURN_FLAG, GESTURE_STARTED, SwipeData;
var RETURN_FLAG, GESTURE_STARTED, SwipeData, _createClass, Swipe;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
return {

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

execute: function () {
class Swipe {
static defaultOptions() {
return {
radiusThreshold: 2,
touches: 1,
prio: 100,
which: 1
};
_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);
}
}
constructor(subscriber, element) {
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
_export("Swipe", 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;

@@ -34,42 +64,49 @@ this.element = element;

start(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.startPoint = pagePoints[0];
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.down(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
_createClass(Swipe, [{
key: "start",
value: function start(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.startPoint = pagePoints[0];
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.down(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
}, {
key: "update",
value: function update(event, pagePoints) {
this.data.pagePoints = pagePoints;
update(event, pagePoints) {
this.data.pagePoints = pagePoints;
if (pagePoints[0].distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
}
if (pagePoints[0].distanceTo(this.startPoint) < this.subscriber.options.radiusThreshold) {
return undefined;
this.swipeData.addObservation(pagePoints[0]);
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);
}
}
this.swipeData.addObservation(pagePoints[0]);
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: "end",
value: function end(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.end(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
}
}, {
key: "cancel",
value: function cancel(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.subscriber.cancel(event, this.data, this.element);
}
}]);
end(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.swipeData.addObservation(pagePoints[0]);
this.result = this.subscriber.end(event, this.data, this.element);
return RETURN_FLAG.map(this.result);
}
return Swipe;
})());
cancel(event, pagePoints) {
this.data.pagePoints = pagePoints;
this.subscriber.cancel(event, this.data, this.element);
}
}
_export("Swipe", Swipe);

@@ -76,0 +113,0 @@ }

"use strict";
System.register([], function (_export) {
var _createClass, SwipeData;
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) {
_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;
};
})();
_export("SwipeData", SwipeData = (function () {
function SwipeData(maxObservations) {
_classCallCheck(this, SwipeData);
this.maxObservations = maxObservations;

@@ -13,44 +41,50 @@ 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
});
}
if (this.timeSeries.length < 2) {
return 0;
}
getVelocity(velocity) {
var o1, o2, dist, elapsed, v;
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);
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];
}
getDelta() {
var o1, o2, dx, dy;
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;
})());
}
_export("SwipeData", SwipeData);

@@ -57,0 +91,0 @@ }

{
"name": "oribella-swipe",
"version": "0.3.4",
"version": "0.3.5",
"description": "Swipe gesture",

@@ -27,3 +27,3 @@ "license": "MIT",

"dependencies": {
"oribella-framework": "npm:oribella-framework@^0.3.1"
"oribella-framework": "npm:oribella-framework@^0.3.4"
},

@@ -38,4 +38,4 @@ "devDependencies": {

"jspm": "^0.16.15",
"oribella-dev": "^0.1.6"
"oribella-dev": "^0.1.7"
}
}
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