Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58261f2ace | ||
|
|
ebef76a2c6 | ||
|
|
be5e338869 | ||
|
|
cf8cea8b13 | ||
|
|
74f97e330e | ||
|
|
b461fa895b | ||
|
|
af7194114a | ||
|
|
540834308e |
@@ -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
|
||||
}
|
||||
|
||||
@@ -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']
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
4
min/perfect-scrollbar-0.4.2.min.js
vendored
4
min/perfect-scrollbar-0.4.2.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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
4
min/perfect-scrollbar-0.4.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
min/perfect-scrollbar-0.4.4.with-mousewheel.min.js
vendored
Normal file
4
min/perfect-scrollbar-0.4.4.with-mousewheel.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "perfect-scrollbar",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.4",
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user