Skip to content

Commit

Permalink
Update plugin to version 3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
malihu committed Jul 6, 2016
1 parent 3dcf281 commit 2a5c2c1
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 54 deletions.
10 changes: 10 additions & 0 deletions examples/iframe_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
$("#iframe-container").mCustomScrollbar({
axis:"yx",
theme:"light-thick"
}).on("mouseenter",function(){ //cross-domain iframe mousewheel hack
$(this).find("iframe").css("pointer-events","none");
}).on("mouseup",function(){
if(!$(this).find(".mCSB_scrollTools_onDrag").length) return;
setTimeout(function(){ $("#iframe-container").trigger("mouseenter"); },1);
});
$(window).on("blur",function(){
$("#iframe-container iframe").css("pointer-events","auto");
}).on("focus",function(){
$("#iframe-container").trigger("mouseenter");
});

});
Expand Down
6 changes: 3 additions & 3 deletions jquery.mCustomScrollbar.concat.min.js

Large diffs are not rendered by default.

53 changes: 32 additions & 21 deletions jquery.mCustomScrollbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
== malihu jquery custom scrollbar plugin ==
Version: 3.1.4
Version: 3.1.5
Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
Author: malihu
Author URI: http://manos.malihu.gr
Expand Down Expand Up @@ -37,7 +37,9 @@ and dependencies (minified).
*/

(function(factory){
if(typeof module!=="undefined" && module.exports){
if(typeof define==="function" && define.amd){
define(["jquery"],factory);
}else if(typeof module!=="undefined" && module.exports){
module.exports=factory;
}else{
factory(jQuery,window,document);
Expand Down Expand Up @@ -860,7 +862,7 @@ and dependencies (minified).
_pluginMarkup=function(){
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
expandClass=o.autoExpandScrollbar ? " "+classes[1]+"_expand" : "",
scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
wrapperClass=o.axis==="yx" ? "mCSB_vertical_horizontal" : o.axis==="x" ? "mCSB_horizontal" : "mCSB_vertical",
scrollbars=o.axis==="yx" ? scrollbar[0]+scrollbar[1] : o.axis==="x" ? scrollbar[1] : scrollbar[0],
contentWrapper=o.axis==="yx" ? "<div id='mCSB_"+d.idx+"_container_wrapper' class='mCSB_container_wrapper' />" : "",
Expand Down Expand Up @@ -941,10 +943,10 @@ and dependencies (minified).
mCSB_scrollTools=$(".mCSB_"+d.idx+"_scrollbar:first"),
tabindex=!_isNumeric(o.scrollButtons.tabindex) ? "" : "tabindex='"+o.scrollButtons.tabindex+"'",
btnHTML=[
"<a href='#' class='"+classes[13]+"' oncontextmenu='return false;' "+tabindex+" />",
"<a href='#' class='"+classes[14]+"' oncontextmenu='return false;' "+tabindex+" />",
"<a href='#' class='"+classes[15]+"' oncontextmenu='return false;' "+tabindex+" />",
"<a href='#' class='"+classes[16]+"' oncontextmenu='return false;' "+tabindex+" />"
"<a href='#' class='"+classes[13]+"' "+tabindex+" />",
"<a href='#' class='"+classes[14]+"' "+tabindex+" />",
"<a href='#' class='"+classes[15]+"' "+tabindex+" />",
"<a href='#' class='"+classes[16]+"' "+tabindex+" />"
],
btn=[(o.axis==="x" ? btnHTML[2] : btnHTML[0]),(o.axis==="x" ? btnHTML[3] : btnHTML[1]),btnHTML[2],btnHTML[3]];
if(o.scrollButtons.enable){
Expand Down Expand Up @@ -1188,13 +1190,15 @@ and dependencies (minified).
draggable,dragY,dragX,
rds=o.advanced.releaseDraggableSelectors ? mCSB_dragger.add($(o.advanced.releaseDraggableSelectors)) : mCSB_dragger,
eds=o.advanced.extraDraggableSelectors ? $(!_canAccessIFrame() || top.document).add($(o.advanced.extraDraggableSelectors)) : $(!_canAccessIFrame() || top.document);
mCSB_dragger.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
mCSB_dragger.bind("contextmenu."+namespace,function(e){
e.preventDefault(); //prevent right click
}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
e.stopImmediatePropagation();
e.preventDefault();
if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
touchActive=true;
if(oldIE){document.onselectstart=function(){return false;}} /* disable text selection for IE < 9 */
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
_iframe.call(mCSB_container,false); /* enable scrollbar dragging over iframes by disabling their events */
_stop($this);
draggable=$(this);
var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left,
Expand Down Expand Up @@ -1223,14 +1227,8 @@ and dependencies (minified).
}
touchActive=false;
if(oldIE){document.onselectstart=null;} /* enable text selection for IE < 9 */
_iframe(true); /* enable iframes events */
_iframe.call(mCSB_container,true); /* enable iframes events */
});
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" */
}
function _drag(dragY,dragX,y,x){
mCSB_container[0].idleTimer=o.scrollInertia<233 ? 250 : 0;
if(draggable.attr("id")===draggerId[1]){
Expand Down Expand Up @@ -1263,7 +1261,7 @@ and dependencies (minified).
"touchmove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace, //move
"touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace //end
],
touchAction=document.body.style.touchAction!==undefined;
touchAction=document.body.style.touchAction!==undefined && document.body.style.touchAction!=="";
mCSB_container.bind(events[0],function(e){
_onTouchstart(e);
}).bind(events[1],function(e){
Expand Down Expand Up @@ -1542,6 +1540,16 @@ and dependencies (minified).
/* -------------------- */


/* switches iframe's pointer-events property (drag, mousewheel etc. over cross-domain iframes) */
_iframe=function(evt){
var el=this.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" */
},
/* -------------------- */


/* disables mouse-wheel when hovering specific elements like select, datalist etc. */
_disableMousewheel=function(el,target){
var tag=target.nodeName.toLowerCase(),
Expand Down Expand Up @@ -1653,7 +1661,9 @@ and dependencies (minified).
namespace=pluginPfx+"_"+d.idx,
sel=".mCSB_"+d.idx+"_scrollbar",
btn=$(sel+">a");
btn.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
btn.bind("contextmenu."+namespace,function(e){
e.preventDefault(); //prevent right click
}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
e.preventDefault();
if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
var btnClass=$(this).attr("class");
Expand Down Expand Up @@ -2424,13 +2434,14 @@ and dependencies (minified).
cPos[1]+_childPos($el)[1]>=0 && cPos[1]+_childPos($el)[1]<wrapper.width()-$el.outerWidth(false);
},
/* checks if element or part of element is in view of scrollable viewport */
mcsInSight:$.expr[":"].mcsInSight || function(el){
var $el=$(el),elD,content=$el.parents(".mCSB_container"),wrapperView,pos,wrapperViewPct;
mcsInSight:$.expr[":"].mcsInSight || function(el,i,m){
var $el=$(el),elD,content=$el.parents(".mCSB_container"),wrapperView,pos,wrapperViewPct,
pctVals=m[3]==="exact" ? [[1,0],[1,0]] : [[0.9,0.1],[0.6,0.4]];
if(!content.length){return;}
elD=[$el.outerHeight(false),$el.outerWidth(false)];
pos=[content[0].offsetTop+_childPos($el)[0],content[0].offsetLeft+_childPos($el)[1]];
wrapperView=[content.parent()[0].offsetHeight,content.parent()[0].offsetWidth];
wrapperViewPct=[elD[0]<wrapperView[0] ? [0.9,0.1] : [0.6,0.4],elD[1]<wrapperView[1] ? [0.9,0.1] : [0.6,0.4]];
wrapperViewPct=[elD[0]<wrapperView[0] ? pctVals[0] : pctVals[1],elD[1]<wrapperView[1] ? pctVals[0] : pctVals[1]];
return pos[0]-(wrapperView[0]*wrapperViewPct[0][0])<0 && pos[0]+elD[0]-(wrapperView[0]*wrapperViewPct[0][1])>=0 &&
pos[1]-(wrapperView[1]*wrapperViewPct[1][0])<0 && pos[1]+elD[1]-(wrapperView[1]*wrapperViewPct[1][1])>=0;
},
Expand Down
6 changes: 3 additions & 3 deletions 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.
53 changes: 32 additions & 21 deletions js/uncompressed/jquery.mCustomScrollbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
== malihu jquery custom scrollbar plugin ==
Version: 3.1.4
Version: 3.1.5
Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
Author: malihu
Author URI: http://manos.malihu.gr
Expand Down Expand Up @@ -37,7 +37,9 @@ and dependencies (minified).
*/

(function(factory){
if(typeof module!=="undefined" && module.exports){
if(typeof define==="function" && define.amd){
define(["jquery"],factory);
}else if(typeof module!=="undefined" && module.exports){
module.exports=factory;
}else{
factory(jQuery,window,document);
Expand Down Expand Up @@ -860,7 +862,7 @@ and dependencies (minified).
_pluginMarkup=function(){
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
expandClass=o.autoExpandScrollbar ? " "+classes[1]+"_expand" : "",
scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
wrapperClass=o.axis==="yx" ? "mCSB_vertical_horizontal" : o.axis==="x" ? "mCSB_horizontal" : "mCSB_vertical",
scrollbars=o.axis==="yx" ? scrollbar[0]+scrollbar[1] : o.axis==="x" ? scrollbar[1] : scrollbar[0],
contentWrapper=o.axis==="yx" ? "<div id='mCSB_"+d.idx+"_container_wrapper' class='mCSB_container_wrapper' />" : "",
Expand Down Expand Up @@ -941,10 +943,10 @@ and dependencies (minified).
mCSB_scrollTools=$(".mCSB_"+d.idx+"_scrollbar:first"),
tabindex=!_isNumeric(o.scrollButtons.tabindex) ? "" : "tabindex='"+o.scrollButtons.tabindex+"'",
btnHTML=[
"<a href='#' class='"+classes[13]+"' oncontextmenu='return false;' "+tabindex+" />",
"<a href='#' class='"+classes[14]+"' oncontextmenu='return false;' "+tabindex+" />",
"<a href='#' class='"+classes[15]+"' oncontextmenu='return false;' "+tabindex+" />",
"<a href='#' class='"+classes[16]+"' oncontextmenu='return false;' "+tabindex+" />"
"<a href='#' class='"+classes[13]+"' "+tabindex+" />",
"<a href='#' class='"+classes[14]+"' "+tabindex+" />",
"<a href='#' class='"+classes[15]+"' "+tabindex+" />",
"<a href='#' class='"+classes[16]+"' "+tabindex+" />"
],
btn=[(o.axis==="x" ? btnHTML[2] : btnHTML[0]),(o.axis==="x" ? btnHTML[3] : btnHTML[1]),btnHTML[2],btnHTML[3]];
if(o.scrollButtons.enable){
Expand Down Expand Up @@ -1188,13 +1190,15 @@ and dependencies (minified).
draggable,dragY,dragX,
rds=o.advanced.releaseDraggableSelectors ? mCSB_dragger.add($(o.advanced.releaseDraggableSelectors)) : mCSB_dragger,
eds=o.advanced.extraDraggableSelectors ? $(!_canAccessIFrame() || top.document).add($(o.advanced.extraDraggableSelectors)) : $(!_canAccessIFrame() || top.document);
mCSB_dragger.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
mCSB_dragger.bind("contextmenu."+namespace,function(e){
e.preventDefault(); //prevent right click
}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
e.stopImmediatePropagation();
e.preventDefault();
if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
touchActive=true;
if(oldIE){document.onselectstart=function(){return false;}} /* disable text selection for IE < 9 */
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
_iframe.call(mCSB_container,false); /* enable scrollbar dragging over iframes by disabling their events */
_stop($this);
draggable=$(this);
var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left,
Expand Down Expand Up @@ -1223,14 +1227,8 @@ and dependencies (minified).
}
touchActive=false;
if(oldIE){document.onselectstart=null;} /* enable text selection for IE < 9 */
_iframe(true); /* enable iframes events */
_iframe.call(mCSB_container,true); /* enable iframes events */
});
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" */
}
function _drag(dragY,dragX,y,x){
mCSB_container[0].idleTimer=o.scrollInertia<233 ? 250 : 0;
if(draggable.attr("id")===draggerId[1]){
Expand Down Expand Up @@ -1263,7 +1261,7 @@ and dependencies (minified).
"touchmove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace, //move
"touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace //end
],
touchAction=document.body.style.touchAction!==undefined;
touchAction=document.body.style.touchAction!==undefined && document.body.style.touchAction!=="";
mCSB_container.bind(events[0],function(e){
_onTouchstart(e);
}).bind(events[1],function(e){
Expand Down Expand Up @@ -1542,6 +1540,16 @@ and dependencies (minified).
/* -------------------- */


/* switches iframe's pointer-events property (drag, mousewheel etc. over cross-domain iframes) */
_iframe=function(evt){
var el=this.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" */
},
/* -------------------- */


/* disables mouse-wheel when hovering specific elements like select, datalist etc. */
_disableMousewheel=function(el,target){
var tag=target.nodeName.toLowerCase(),
Expand Down Expand Up @@ -1653,7 +1661,9 @@ and dependencies (minified).
namespace=pluginPfx+"_"+d.idx,
sel=".mCSB_"+d.idx+"_scrollbar",
btn=$(sel+">a");
btn.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
btn.bind("contextmenu."+namespace,function(e){
e.preventDefault(); //prevent right click
}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
e.preventDefault();
if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
var btnClass=$(this).attr("class");
Expand Down Expand Up @@ -2424,13 +2434,14 @@ and dependencies (minified).
cPos[1]+_childPos($el)[1]>=0 && cPos[1]+_childPos($el)[1]<wrapper.width()-$el.outerWidth(false);
},
/* checks if element or part of element is in view of scrollable viewport */
mcsInSight:$.expr[":"].mcsInSight || function(el){
var $el=$(el),elD,content=$el.parents(".mCSB_container"),wrapperView,pos,wrapperViewPct;
mcsInSight:$.expr[":"].mcsInSight || function(el,i,m){
var $el=$(el),elD,content=$el.parents(".mCSB_container"),wrapperView,pos,wrapperViewPct,
pctVals=m[3]==="exact" ? [[1,0],[1,0]] : [[0.9,0.1],[0.6,0.4]];
if(!content.length){return;}
elD=[$el.outerHeight(false),$el.outerWidth(false)];
pos=[content[0].offsetTop+_childPos($el)[0],content[0].offsetLeft+_childPos($el)[1]];
wrapperView=[content.parent()[0].offsetHeight,content.parent()[0].offsetWidth];
wrapperViewPct=[elD[0]<wrapperView[0] ? [0.9,0.1] : [0.6,0.4],elD[1]<wrapperView[1] ? [0.9,0.1] : [0.6,0.4]];
wrapperViewPct=[elD[0]<wrapperView[0] ? pctVals[0] : pctVals[1],elD[1]<wrapperView[1] ? pctVals[0] : pctVals[1]];
return pos[0]-(wrapperView[0]*wrapperViewPct[0][0])<0 && pos[0]+elD[0]-(wrapperView[0]*wrapperViewPct[0][1])>=0 &&
pos[1]-(wrapperView[1]*wrapperViewPct[1][0])<0 && pos[1]+elD[1]-(wrapperView[1]*wrapperViewPct[1][1])>=0;
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "malihu-custom-scrollbar-plugin",
"version": "3.1.4",
"version": "3.1.5",
"author": "malihu (http://manos.malihu.gr)",
"description": "Highly customizable custom scrollbar jQuery plugin, featuring vertical/horizontal scrollbars, scrolling momentum, mouse-wheel, keyboard and touch support user defined callbacks etc.",
"license": "MIT",
Expand All @@ -20,6 +20,7 @@
],
"files": [
"jquery.mCustomScrollbar.js",
"jquery.mCustomScrollbar.concat.min.js",
"jquery.mCustomScrollbar.css",
"mCSB_buttons.png",
"readme.md"
Expand Down
Loading

0 comments on commit 2a5c2c1

Please sign in to comment.