Compare commits

...

8 Commits
0.4.2 ... 0.4.4

Author SHA1 Message Date
Hyunje Alex Jun
58261f2ace Release 0.4.4.
Patch notes
1. Bug fixes.
2013-09-09 10:44:48 +09:00
Hyunje Alex Jun
ebef76a2c6 Add unbind for 'document'.
The function call is needed cause there are mouse handlers
for the element.
2013-09-09 10:12:35 +09:00
Hyunje Alex Jun
be5e338869 Update jshintrc.
Added strict, laxcomma and camelcase options.
Removed the es5 option.
2013-08-31 02:24:43 +09:00
Hyunje Alex Jun
cf8cea8b13 Fix that wheelPropagation option doesn't work in Firefox. 2013-08-06 15:14:55 +09:00
Fabian Vogelsteller
74f97e330e reduced the risk of memory leaks 2013-08-06 14:18:21 +09:00
Hyunje Alex Jun
b461fa895b Release 0.4.3.
Patch notes
1. Quick fix for the scrolling problem in Firefox.
2013-08-01 02:16:44 +09:00
Hyunje Alex Jun
af7194114a Fix Firefox scrolling problem in OS X.
In OS X, there was the problem that the mousewheel event's
preventDefault() doesn't work well. This patch fixes the problem.
2013-08-01 02:03:44 +09:00
Hyunje Alex Jun
540834308e Fix typos in README.md. 2013-08-01 01:33:10 +09:00
11 changed files with 75 additions and 31 deletions

View File

@@ -22,8 +22,7 @@
"debug" : false,
"devel" : true,
"es5" : true,
"strict" : false,
"strict" : true,
"globalstrict" : true,
"asi" : false,
@@ -56,5 +55,7 @@
"sub" : false,
"trailing" : true,
"white" : true,
"indent" : 2
"indent" : 2,
"laxcomma" : true,
"camelcase" : true
}

View File

@@ -27,7 +27,7 @@ module.exports = function (grunt) {
'src/jquery.mousewheel.js'
]
}
},
}
},
jshint: {
gruntfile: {
@@ -47,7 +47,7 @@ module.exports = function (grunt) {
strict: {
options: {
csslintrc: '.csslintrc',
import: 2
'import': 2
},
src: ['src/perfect-scrollbar.css']
}

View File

@@ -63,7 +63,7 @@ If this option is true, when the scroll reach the end of the side, mousewheel ev
Default: false
### minScrollbarLength
When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels
When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels.
Default: null
How to Use

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
/*! perfect-scrollbar - v0.4.2
/*! perfect-scrollbar - v0.4.4
* http://noraesae.github.com/perfect-scrollbar/
* Copyright (c) 2013 HyeonJe Jun; Licensed MIT */

4
min/perfect-scrollbar-0.4.4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "perfect-scrollbar",
"version": "0.4.2",
"version": "0.4.4",
"engines": {
"node": ">= 0.8.0"
},

View File

@@ -2,7 +2,7 @@
"name": "perfect-scrollbar",
"title": "perfect-scrollbar",
"description": "Tiny but perfect jquery scrollbar plugin.",
"version": "0.4.2",
"version": "0.4.4",
"author": {
"name": "HyeonJe Jun",
"email": "noraesae@yuiazu.net",

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2012 HyeonJe Jun (http://github.com/noraesae)
* Licensed under the MIT License
*/
'use strict';
((function ($) {
// The default settings for the plugin
@@ -14,7 +15,9 @@
return this.each(function () {
// Use the default settings
var settings = $.extend(true, {}, defaultSettings);
var settings = $.extend(true, {}, defaultSettings),
$this = $(this);
if (typeof suppliedSettings === "object") {
// But over-ride any supplied
$.extend(true, settings, suppliedSettings);
@@ -23,26 +26,33 @@
option = suppliedSettings;
}
// Catch options
if (option === 'update') {
if ($(this).data('perfect-scrollbar-update')) {
$(this).data('perfect-scrollbar-update')();
if ($this.data('perfect-scrollbar-update')) {
$this.data('perfect-scrollbar-update')();
}
return $(this);
return $this;
}
else if (option === 'destroy') {
if ($(this).data('perfect-scrollbar-destroy')) {
$(this).data('perfect-scrollbar-destroy')();
if ($this.data('perfect-scrollbar-destroy')) {
$this.data('perfect-scrollbar-destroy')();
}
return $(this);
return $this;
}
if ($(this).data('perfect-scrollbar')) {
if ($this.data('perfect-scrollbar')) {
// if there's already perfect-scrollbar
return $(this).data('perfect-scrollbar');
return $this.data('perfect-scrollbar');
}
var $this = $(this).addClass('ps-container'),
$scrollbarX = $("<div class='ps-scrollbar-x'></div>").appendTo($this),
// Or generate new perfectScrollbar
// Set class to the container
$this.addClass('ps-container');
var $scrollbarX = $("<div class='ps-scrollbar-x'></div>").appendTo($this),
$scrollbarY = $("<div class='ps-scrollbar-y'></div>").appendTo($this),
containerWidth,
containerHeight,
@@ -84,6 +94,7 @@
containerHeight = $this.height();
contentWidth = $this.prop('scrollWidth');
contentHeight = $this.prop('scrollHeight');
if (containerWidth < contentWidth) {
scrollbarXWidth = getSettingsAdjustedThumbSize(parseInt(containerWidth * containerWidth / contentWidth, 10));
scrollbarXLeft = parseInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth), 10);
@@ -93,6 +104,7 @@
scrollbarXLeft = 0;
$this.scrollLeft(0);
}
if (containerHeight < contentHeight) {
scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(containerHeight * containerHeight / contentHeight, 10));
scrollbarYTop = parseInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight), 10);
@@ -171,6 +183,9 @@
$scrollbarX.removeClass('in-scrolling');
}
});
currentLeft =
currentPageX = null;
};
var bindMouseScrollYHandler = function () {
@@ -199,6 +214,9 @@
$scrollbarY.removeClass('in-scrolling');
}
});
currentTop =
currentPageY = null;
};
// bind handlers
@@ -222,6 +240,7 @@
return true;
};
var shouldPrevent = false;
$this.bind('mousewheel.perfect-scroll', function (e, delta, deltaX, deltaY) {
$this.scrollTop($this.scrollTop() - (deltaY * settings.wheelSpeed));
$this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed));
@@ -229,7 +248,15 @@
// update bar position
updateBarSizeAndPosition();
if (shouldPreventDefault(deltaX, deltaY)) {
shouldPrevent = shouldPreventDefault(deltaX, deltaY);
if (shouldPrevent) {
e.preventDefault();
}
});
// fix Firefox scroll problem
$this.bind('MozMousePixelScroll.perfect-scroll', function (e) {
if (shouldPrevent) {
e.preventDefault();
}
});
@@ -295,6 +322,7 @@
}
});
$this.bind("touchend.perfect-scroll", function (e) {
clearInterval(breakingProcess);
breakingProcess = setInterval(function () {
if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(breakingProcess);
@@ -310,13 +338,28 @@
};
var destroy = function () {
$scrollbarX.remove();
$scrollbarY.remove();
$this.unbind('.perfect-scroll');
$(window).unbind('.perfect-scroll');
$(document).unbind('.perfect-scroll');
$this.data('perfect-scrollbar', null);
$this.data('perfect-scrollbar-update', null);
$this.data('perfect-scrollbar-destroy', null);
$scrollbarX.remove();
$scrollbarY.remove();
// clean all variables
$scrollbarX =
$scrollbarY =
containerWidth =
containerHeight =
contentWidth =
contentHeight =
scrollbarXWidth =
scrollbarXLeft =
scrollbarXBottom =
scrollbarYHeight =
scrollbarYTop =
scrollbarYRight = null;
};
var ieSupport = function (version) {