Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Jun 23, 2011
1 parent d2257d0 commit 378ee5f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scrollr.js
@@ -1,6 +1,6 @@
(function (win, doc) {
//
var
//
_defined = function(valA, valB) {
return valA != undefined ? valA : valB;
};
Expand Down Expand Up @@ -75,24 +75,22 @@
this.widthDiff = Math.min(elementFrameWidth - contentWidth, 0);
this.contentStartOffsetX = transform.m41;
this.contentStartOffsetY = transform.m42;
// start time
this._startTime = e.timeStamp;
},
setVelocity: function (e) {
// client
var
eTouches = e.touches,
clientX = eTouches ? eTouches[0].clientX : e.clientX,
clientY = eTouches ? eTouches[0].clientY : e.clientY;
// end time
this._endTime = e.timeStamp;
// velocity
this.velocityX = Math.abs((clientX - this.startTouchX) / (this._endTime - this._startTime));
this.velocityY = Math.abs((clientY - this.startTouchY) / (this._endTime - this._startTime));
},
onTouchStart: function (e) {
// not touching
this.touching = true;
// start time
this._startTime = e.timeStamp;
// initialize velocity
this.velocityX = 1;
this.velocityY = 1;
Expand All @@ -106,10 +104,10 @@
this.startTouchY = (eTouches) ? eTouches[0].clientY : e.clientY;
},
onTouchMove: function (e) {
// disable selection
this.element.style.WebkitUserSelect = 'none';
// get end velocity
this.setVelocity(e);
// disable selection
this.element.style.WebkitUserSelect = 'none';
//
var
eTouches = e.touches,
Expand Down Expand Up @@ -143,6 +141,8 @@
onTouchEnd: function (e) {
// not touching
this.touching = false;
// end time
this._endTime = e.timeStamp;
// disable selection
this.element.style.WebkitUserSelect = '';
// momentum
Expand Down

0 comments on commit 378ee5f

Please sign in to comment.