Skip to content

Commit

Permalink
Update plugin to version 2.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
malihu committed May 18, 2014
1 parent 8ae51c7 commit b4b48a4
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 91 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "malihu-custom-scrollbar-plugin",
"version": "2.8.6",
"version": "2.8.7",
"title": "malihu custom scrollbar plugin",
"description": "Highly customizable custom scrollbar jQuery plugin, featuring vertical/horizontal scrollbars, scrolling momentum, mouse-wheel and touch support user defined callbacks etc.",
"main": "./jquery.mCustomScrollbar.js",
Expand Down
8 changes: 4 additions & 4 deletions jquery.mCustomScrollbar.concat.min.js

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions jquery.mCustomScrollbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
== malihu jquery custom scrollbars plugin ==
version: 2.8.6
version: 2.8.7
author: malihu (http://manos.malihu.gr)
plugin home: http://manos.malihu.gr/jquery-custom-content-scroller
*/
Expand Down Expand Up @@ -230,7 +230,7 @@ THE SOFTWARE.
$this.data("mCSB_onContentResize",setInterval(function(){
if(options.horizontalScroll){
if(options.advanced.autoExpandHorizontalScroll){
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),"position":"relative"}).unwrap();
}
var mCSB_containerNewSize=mCSB_container.outerWidth(),mCSB_contentNewSize=mCSB_container.innerWidth();
}else{
Expand Down Expand Up @@ -260,7 +260,7 @@ THE SOFTWARE.
mCSB_buttonRight=mCSB_scrollTools.children(".mCSB_buttonRight"),
mCustomScrollBoxW=mCustomScrollBox.width();
if($this.data("autoExpandHorizontalScroll")){
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),"position":"relative"}).unwrap();
}
var mCSB_containerW=mCSB_container.outerWidth();
}else{
Expand Down Expand Up @@ -355,6 +355,7 @@ THE SOFTWARE.
if($.support.pointer || $.support.msPointer){ /*pointer, MSPointer*/
mCSB_dragger.bind(mCSB_dragger_downEvent,function(e){
e.preventDefault();
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
$this.data({"on_drag":true}); mCSB_dragger.addClass("mCSB_dragger_onDrag");
$this.data("onDragStart_Callback").call($this);
var elem=$(this),
Expand All @@ -378,10 +379,12 @@ THE SOFTWARE.
}).bind(mCSB_dragger_upEvent+"."+$this.data("mCustomScrollbarIndex"),function(e){
$this.data({"on_drag":false}); mCSB_dragger.removeClass("mCSB_dragger_onDrag");
$this.data("onDragStop_Callback").call($this);
_iframe(true); /* enable iframes events */
});
}else{ /*mouse/touch*/
mCSB_dragger.bind("mousedown touchstart",function(e){
e.preventDefault(); e.stopImmediatePropagation();
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
var elem=$(this),elemOffset=elem.offset(),x,y;
if(e.type==="touchstart"){
var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
Expand Down Expand Up @@ -414,6 +417,7 @@ THE SOFTWARE.
}).bind("mouseup."+$this.data("mCustomScrollbarIndex"),function(e){
$this.data({"on_drag":false}); mCSB_dragger.removeClass("mCSB_dragger_onDrag");
$this.data("onDragStop_Callback").call($this);
_iframe(true); /* enable iframes events */
});
}
$this.data({"bindEvent_scrollbar_drag":true});
Expand Down Expand Up @@ -478,12 +482,15 @@ THE SOFTWARE.
if(delta<0){delta=-1;}else{delta=1;}
}
if(mouseWheelPixels==="auto"){
mouseWheelPixels=100+Math.round($this.data("scrollAmount")/2);
mouseWheelPixels=100*Math.round($this.data("scrollAmount"));
}
if($this.data("horizontalScroll")){
draggerPos=mCSB_dragger.position().left;
limit=mCSB_draggerContainer.width()-mCSB_dragger.width();
absPos=Math.abs(mCSB_container.position().left);
if(mouseWheelPixels>=mCustomScrollBox.width()){mouseWheelPixels=mCustomScrollBox.width()*0.9;}
}else{
if(mouseWheelPixels>=mCustomScrollBox.height()){mouseWheelPixels=mCustomScrollBox.height()*0.9;}
}
if((delta>0 && draggerPos!==0) || (delta<0 && draggerPos!==limit)){e.preventDefault(); e.stopImmediatePropagation();}
scrollTo=absPos-(delta*mouseWheelPixels);
Expand All @@ -492,6 +499,12 @@ THE SOFTWARE.
$this.data({"bindEvent_mousewheel":true});
}
}
function _iframe(evt){
var el=mCSB_container.find("iframe");
if(!el.length){return;} /* check if content contains iframes */
var val=!evt ? "none" : "auto";
el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */
}
/*buttons scrolling*/
if($this.data("scrollButtons_enable")){
if($this.data("scrollButtons_scrollType")==="pixels"){ /*scroll by pixels*/
Expand Down Expand Up @@ -997,7 +1010,7 @@ THE SOFTWARE.
$.support.msPointer=window.navigator.msPointerEnabled; /*MSPointer support*/
/*plugin dependencies*/
var _dlp=("https:"==document.location.protocol) ? "https:" : "http:";
$.event.special.mousewheel || $("<script>",{src:_dlp+"//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.6/jquery.mousewheel.min.js"}).appendTo("body");
$.event.special.mousewheel || $("<script>",{src:_dlp+"//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.11/jquery.mousewheel.min.js"}).appendTo("body");
/*plugin fn*/
$.fn.mCustomScrollbar=function(method){
if(methods[method]){
Expand Down
2 changes: 1 addition & 1 deletion js/minified/jquery.mCustomScrollbar.min.js

Large diffs are not rendered by default.

Binary file modified js/minified/jquery.mCustomScrollbar.min.js.gz
Binary file not shown.
12 changes: 12 additions & 0 deletions js/minified/jquery.mousewheel-3.0.6.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/
(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
12 changes: 4 additions & 8 deletions js/minified/jquery.mousewheel.min.js

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

21 changes: 17 additions & 4 deletions js/uncompressed/jquery.mCustomScrollbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
== malihu jquery custom scrollbars plugin ==
version: 2.8.6
version: 2.8.7
author: malihu (http://manos.malihu.gr)
plugin home: http://manos.malihu.gr/jquery-custom-content-scroller
*/
Expand Down Expand Up @@ -230,7 +230,7 @@ THE SOFTWARE.
$this.data("mCSB_onContentResize",setInterval(function(){
if(options.horizontalScroll){
if(options.advanced.autoExpandHorizontalScroll){
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),"position":"relative"}).unwrap();
}
var mCSB_containerNewSize=mCSB_container.outerWidth(),mCSB_contentNewSize=mCSB_container.innerWidth();
}else{
Expand Down Expand Up @@ -260,7 +260,7 @@ THE SOFTWARE.
mCSB_buttonRight=mCSB_scrollTools.children(".mCSB_buttonRight"),
mCustomScrollBoxW=mCustomScrollBox.width();
if($this.data("autoExpandHorizontalScroll")){
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),"position":"relative"}).unwrap();
}
var mCSB_containerW=mCSB_container.outerWidth();
}else{
Expand Down Expand Up @@ -355,6 +355,7 @@ THE SOFTWARE.
if($.support.pointer || $.support.msPointer){ /*pointer, MSPointer*/
mCSB_dragger.bind(mCSB_dragger_downEvent,function(e){
e.preventDefault();
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
$this.data({"on_drag":true}); mCSB_dragger.addClass("mCSB_dragger_onDrag");
$this.data("onDragStart_Callback").call($this);
var elem=$(this),
Expand All @@ -378,10 +379,12 @@ THE SOFTWARE.
}).bind(mCSB_dragger_upEvent+"."+$this.data("mCustomScrollbarIndex"),function(e){
$this.data({"on_drag":false}); mCSB_dragger.removeClass("mCSB_dragger_onDrag");
$this.data("onDragStop_Callback").call($this);
_iframe(true); /* enable iframes events */
});
}else{ /*mouse/touch*/
mCSB_dragger.bind("mousedown touchstart",function(e){
e.preventDefault(); e.stopImmediatePropagation();
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
var elem=$(this),elemOffset=elem.offset(),x,y;
if(e.type==="touchstart"){
var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
Expand Down Expand Up @@ -414,6 +417,7 @@ THE SOFTWARE.
}).bind("mouseup."+$this.data("mCustomScrollbarIndex"),function(e){
$this.data({"on_drag":false}); mCSB_dragger.removeClass("mCSB_dragger_onDrag");
$this.data("onDragStop_Callback").call($this);
_iframe(true); /* enable iframes events */
});
}
$this.data({"bindEvent_scrollbar_drag":true});
Expand Down Expand Up @@ -478,12 +482,15 @@ THE SOFTWARE.
if(delta<0){delta=-1;}else{delta=1;}
}
if(mouseWheelPixels==="auto"){
mouseWheelPixels=100+Math.round($this.data("scrollAmount")/2);
mouseWheelPixels=100*Math.round($this.data("scrollAmount"));
}
if($this.data("horizontalScroll")){
draggerPos=mCSB_dragger.position().left;
limit=mCSB_draggerContainer.width()-mCSB_dragger.width();
absPos=Math.abs(mCSB_container.position().left);
if(mouseWheelPixels>=mCustomScrollBox.width()){mouseWheelPixels=mCustomScrollBox.width()*0.9;}
}else{
if(mouseWheelPixels>=mCustomScrollBox.height()){mouseWheelPixels=mCustomScrollBox.height()*0.9;}
}
if((delta>0 && draggerPos!==0) || (delta<0 && draggerPos!==limit)){e.preventDefault(); e.stopImmediatePropagation();}
scrollTo=absPos-(delta*mouseWheelPixels);
Expand All @@ -492,6 +499,12 @@ THE SOFTWARE.
$this.data({"bindEvent_mousewheel":true});
}
}
function _iframe(evt){
var el=mCSB_container.find("iframe");
if(!el.length){return;} /* check if content contains iframes */
var val=!evt ? "none" : "auto";
el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */
}
/*buttons scrolling*/
if($this.data("scrollButtons_enable")){
if($this.data("scrollButtons_scrollType")==="pixels"){ /*scroll by pixels*/
Expand Down
84 changes: 84 additions & 0 deletions js/uncompressed/jquery.mousewheel-3.0.6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

if ($.event.fixHooks) {
for ( var i=types.length; i; ) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}

$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},

teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};

$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},

unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});


function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";

// Old school scrollwheel delta
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }

// New school multidimensional scroll (touchpads) deltas
deltaY = delta;

// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}

// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }

// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);

return ($.event.dispatch || $.event.handle).apply(this, args);
}

})(jQuery);
Loading

0 comments on commit b4b48a4

Please sign in to comment.