Skip to content

Commit

Permalink
Merge branch 'tsaikd-master'
Browse files Browse the repository at this point in the history
* tsaikd-master:
  Release v2.2.0
  add option selectStart for customization
  move selectStart to _initEvents and test with _useTarget
  add invert option
  use _getScroller() in _move()
  • Loading branch information
davetayls committed Sep 9, 2015
2 parents a01bc47 + 6ff19d3 commit c4106ec
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery.kinetic",
"main": "jquery.kinetic.js",
"version": "2.1.1",
"version": "2.2.0",
"homepage": "http://davetayls.me/jquery.kinetic",
"authors": [
"davetayls <[email protected]>"
Expand Down
32 changes: 24 additions & 8 deletions jquery.kinetic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
jQuery.kinetic v2.1.1
jQuery.kinetic v2.2.0
Dave Taylor http://davetayls.me
@license The MIT License (MIT)
Expand Down Expand Up @@ -35,9 +35,6 @@
$.extend($.support, {
touch: 'ontouchend' in document
});
var selectStart = function (){
return false;
};


// KINETIC CLASS DEFINITION
Expand All @@ -64,6 +61,7 @@
slowdown: 0.9,
maxvelocity: 40,
throttleFPS: 60,
invert: false,
movingClass: {
up: 'kinetic-moving-up',
down: 'kinetic-moving-down',
Expand Down Expand Up @@ -226,6 +224,16 @@
if (self._useTarget(e.target, e) && self.elementFocused){
return false;
}
},
// prevent selection when dragging
selectStart: function (e){
if ($.isFunction(self.settings.selectStart)){
return self.settings.selectStart.apply(self, arguments);
} else if (self._useTarget(e.target, e)) {
return false;
} else {
return false;
}
}
};

Expand All @@ -243,6 +251,10 @@
if (this.mouseDown && (this.xpos || this.ypos)){
var movedX = (clientX - this.xpos);
var movedY = (clientY - this.ypos);
if (this.settings.invert) {
movedX *= -1;
movedY *= -1;
}
if(this.threshold > 0){
var moved = Math.sqrt(movedX * movedX + movedY * movedY);
if(this.threshold > moved){
Expand Down Expand Up @@ -284,6 +296,10 @@
Kinetic.prototype._calculateVelocities = function (){
this.velocity = this._capVelocity(this.prevXPos - this.xpos, this.settings.maxvelocity);
this.velocityY = this._capVelocity(this.prevYPos - this.ypos, this.settings.maxvelocity);
if (this.settings.invert) {
this.velocity *= -1;
this.velocityY *= -1;
}
};

Kinetic.prototype._end = function (){
Expand Down Expand Up @@ -375,8 +391,8 @@

// do the actual kinetic movement
Kinetic.prototype._move = function (){
var $scroller = this.$el;
var scroller = this.el;
var $scroller = this._getScroller();
var scroller = $scroller[0];
var self = this;
var settings = self.settings;

Expand Down Expand Up @@ -470,7 +486,7 @@
$this
.click(settings.events.inputClick)
.scroll(settings.events.scroll)
.bind('selectstart', selectStart) // prevent selection when dragging
.bind('selectstart', settings.events.selectStart)
.bind('dragstart', settings.events.dragStart);
};

Expand All @@ -492,7 +508,7 @@
$this
.unbind('click', settings.events.inputClick)
.unbind('scroll', settings.events.scroll)
.unbind('selectstart', selectStart) // prevent selection when dragging
.unbind('selectstart', settings.events.selectStart)
.unbind('dragstart', settings.events.dragStart);
};

Expand Down
4 changes: 2 additions & 2 deletions jquery.kinetic.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.kinetic",
"version": "2.1.1",
"version": "2.2.0",
"description": "adds smooth drag scrolling with gradual deceleration to containers",
"homepage": "http://the-taylors.org/jquery.kinetic",
"author": {
Expand Down
Loading

0 comments on commit c4106ec

Please sign in to comment.