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

famous

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

famous - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

2

bower.json
{
"name": "famous",
"version": "0.3.3",
"version": "0.3.4",
"homepage": "https://github.com/Famous/famous",

@@ -5,0 +5,0 @@ "authors": [

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

## 0.3.4
### Bug Fixes
- Famous/inputs
- 0.3.3 did not fix changes to inputs. All changes from 0.3.2 and 0.3.3 involving inputs have been reverted
## 0.3.3

@@ -2,0 +9,0 @@

{
"name": "famous",
"version": "0.3.3",
"version": "0.3.4",
"description": "Famo.us is a JavaScript framework for everyone who wants to build beautiful experiences on any device.",

@@ -5,0 +5,0 @@ "repository": {

@@ -12,3 +12,2 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

var OptionsManager = require('../core/OptionsManager');
var SyncUtils = require('./SyncUtils');

@@ -83,2 +82,4 @@ /**

this._position = null; // to be deprecated
this._prevCoord = undefined;
this._prevTime = undefined;
this._down = false;

@@ -97,3 +98,2 @@ this._moved = false;

velocitySampleLength: 10,
timeSampleDuration: 400,
preventDefault: true

@@ -120,4 +120,5 @@ };

var y = event.clientY;
var currTime = Date.now();
this._prevCoord = [x, y];
this._prevTime = Date.now();
this._down = true;

@@ -152,5 +153,5 @@ this._move = false;

position: payload.position.slice ? payload.position.slice(0) : payload.position,
clientPosition: [x, y],
timestamp: currTime
time: this._prevTime
});
this._eventOutput.emit('start', payload);

@@ -167,57 +168,7 @@ this._documentActive = false;

function _handleMove(event) {
if (this._positionHistory.length === 0) return;
var payload = calculatePayload.call(this, event);
this._eventOutput.emit('update', payload);
this._move = true;
}
if (!this._prevCoord) return;
/**
* Triggered by mouseup on the element or document body if propagation is enabled, or
* mouseleave if propagation is off.
*
* @method _handleEnd
* @private
*/
function _handleEnd(event) {
if (!this._down) return;
var payload = calculatePayload.call(this, event);
this._eventOutput.emit('end', payload);
this._down = false;
this._move = false;
this._positionHistory = [];
}
var prevCoord = this._prevCoord;
var prevTime = this._prevTime;
/**
* Switches the mousemove listener to the document body, if propagation is enabled.
* @method _handleLeave
* @private
*/
function _handleLeave(event) {
if (!this._down || !this._move) return;
if (!this._documentActive) {
var boundMove = _handleMove.bind(this);
var boundEnd = function(event) {
_handleEnd.call(this, event);
document.removeEventListener('mousemove', boundMove);
document.removeEventListener('mouseup', boundEnd);
}.bind(this);
document.addEventListener('mousemove', boundMove);
document.addEventListener('mouseup', boundEnd);
this._documentActive = true;
}
}
/**
* Calculates the data to send to listeners.
* @method calculatePayload
* @private
*/
function calculatePayload (event) {
var payload = this._payload;
var scale = this.options.scale;
var nextVel;
var nextDelta;
var x = event.clientX;

@@ -228,5 +179,4 @@ var y = event.clientY;

var lastPos = this._positionHistory[this._positionHistory.length - 1];
var diffX = (x * scale) - lastPos.clientPosition[0];
var diffY = (y * scale) - lastPos.clientPosition[1];
var diffX = x - prevCoord[0];
var diffY = y - prevCoord[1];

@@ -237,14 +187,27 @@ if (this.options.rails) {

}
var diffTime = Math.max(currTime - this._positionHistory[0].time, MINIMUM_TICK_TIME); // minimum tick time
var scale = this.options.scale;
var nextVel;
var nextDelta;
if (this.options.direction === MouseSync.DIRECTION_X) {
nextDelta = diffX;
nextDelta = scale * diffX;
this._position += nextDelta;
nextVel = scale * (this._position - this._positionHistory[0].position) / diffTime;
}
else if (this.options.direction === MouseSync.DIRECTION_Y) {
nextDelta = diffY;
nextDelta = scale * diffY;
this._position += nextDelta;
nextVel = scale * (this._position - this._positionHistory[0].position) / diffTime;
}
else {
nextDelta = [diffX, diffY];
this._position[0] += diffX;
this._position[1] += diffY;
nextDelta = [scale * diffX, scale * diffY];
nextVel = [
scale * (this._position[0] - this._positionHistory[0].position[0]) / diffTime,
scale * (this._position[1] - this._positionHistory[0].position[1]) / diffTime
];
this._position[0] += nextDelta[0];
this._position[1] += nextDelta[1];
}

@@ -257,4 +220,6 @@

var payload = this._payload;
payload.delta = nextDelta;
payload.position = this._position;
payload.velocity = nextVel;
payload.clientX = x;

@@ -266,31 +231,57 @@ payload.clientY = y;

if (this._positionHistory.length === this.options.velocitySampleLength) {
this._positionHistory.shift();
this._positionHistory.shift();
}
this._positionHistory.push({
position: payload.position.slice ? payload.position.slice(0) : payload.position,
clientPosition: [x, y],
timestamp: currTime
position: payload.position.slice ? payload.position.slice(0) : payload.position,
time: currTime
});
// Calculate velocity
var lastPositionHistory = SyncUtils.getTimeHistoryPosition(this._positionHistory, this.options.timeSampleDuration);
var diffTime = Math.max(currTime - lastPositionHistory.timestamp, MINIMUM_TICK_TIME); // minimum tick time
this._eventOutput.emit('update', payload);
if (this.options.direction !== undefined) {
nextVel = scale * (this._position - lastPositionHistory.position) / diffTime;
}
else {
nextVel = [
scale * (this._position[0] - lastPositionHistory.position[0]) / diffTime,
scale * (this._position[1] - lastPositionHistory.position[1]) / diffTime
];
}
this._prevCoord = [x, y];
this._prevTime = currTime;
this._move = true;
}
payload.velocity = nextVel;
/**
* Triggered by mouseup on the element or document body if propagation is enabled, or
* mouseleave if propagation is off.
*
* @method _handleEnd
* @private
*/
function _handleEnd(event) {
if (!this._down) return;
return payload;
this._eventOutput.emit('end', this._payload);
this._prevCoord = undefined;
this._prevTime = undefined;
this._down = false;
this._move = false;
this._positionHistory = [];
}
/**
* Switches the mousemove listener to the document body, if propagation is enabled.
* @method _handleLeave
* @private
*/
function _handleLeave(event) {
if (!this._down || !this._move) return;
if (!this._documentActive) {
var boundMove = _handleMove.bind(this);
var boundEnd = function(event) {
_handleEnd.call(this, event);
document.removeEventListener('mousemove', boundMove);
document.removeEventListener('mouseup', boundEnd);
}.bind(this, event);
document.addEventListener('mousemove', boundMove);
document.addEventListener('mouseup', boundEnd);
this._documentActive = true;
}
}
/**
* Return entire options dictionary, including defaults.

@@ -297,0 +288,0 @@ *

@@ -13,3 +13,2 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

var OptionsManager = require('../core/OptionsManager');
var SyncUtils = require('./SyncUtils');

@@ -79,4 +78,3 @@ /**

velocitySampleLength: 10,
scale: 1,
timeSampleDuration: 400
scale: 1
};

@@ -126,11 +124,10 @@

function _handleMove(data) {
calculatePayload.call(this, data);
}
function calculatePayload (data) {
var history = data.history;
var currHistory = history[history.length - 1];
var prevHistory = history[history.length - 2];
var distantHistory = SyncUtils.getTimeHistoryPosition(history, this.options.timeSampleDuration);
var distantHistory = history[history.length - this.options.velocitySampleLength] ?
history[history.length - this.options.velocitySampleLength] :
history[history.length - 2];

@@ -140,7 +137,7 @@ var distantTime = distantHistory.timestamp;

var diffX = currHistory.x - distantHistory.x;
var diffY = currHistory.y - distantHistory.y;
var diffX = currHistory.x - prevHistory.x;
var diffY = currHistory.y - prevHistory.y;
var velDiffX = currHistory.x - distantTime;
var velDiffY = currHistory.y - distantTime;
var velDiffX = currHistory.x - distantHistory.x;
var velDiffY = currHistory.y - distantHistory.y;

@@ -199,3 +196,2 @@ if (this.options.rails) {

function _handleEnd(data) {
calculatePayload.call(this, data);
this._payload.count = data.count;

@@ -202,0 +198,0 @@ this._eventOutput.emit('end', this._payload);

@@ -60,3 +60,2 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

var data = _timestampTouch(touch, event, history);
this.touchHistory[touch.identifier].push(data);
this.eventOutput.emit('trackend', data);

@@ -63,0 +62,0 @@ delete this.touchHistory[touch.identifier];

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