From 719e0d19e12bda8a7d77b55960507190656a8dbc Mon Sep 17 00:00:00 2001 From: Tim Shilov Date: Tue, 22 Jan 2019 13:23:01 +0300 Subject: [PATCH 1/2] Fixes: jQuery 3 syntax fix & slimscroll event fix --- jquery.slimscroll.js | 31 +++++++++++++++---------------- jquery.slimscroll.min.js | 17 +---------------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/jquery.slimscroll.js b/jquery.slimscroll.js index 90caed3..5b54df2 100644 --- a/jquery.slimscroll.js +++ b/jquery.slimscroll.js @@ -2,8 +2,7 @@ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * - * Version: 1.3.8 - * + * Version: 1.3.9 (https://github.com/TimShilov/jQuery-slimScroll) */ (function($) { @@ -220,24 +219,24 @@ // make it draggable and no longer dependent on the jqueryUI if (o.railDraggable){ - bar.bind("mousedown", function(e) { + bar.on("mousedown", function(e) { var $doc = $(document); isDragg = true; t = parseFloat(bar.css('top')); pageY = e.pageY; - $doc.bind("mousemove.slimscroll", function(e){ + $doc.on("mousemove.slimscroll", function(e){ currTop = t + e.pageY - pageY; bar.css('top', currTop); scrollContent(0, bar.position().top, false);// scroll content }); - $doc.bind("mouseup.slimscroll", function(e) { + $doc.on("mouseup.slimscroll", function(e) { isDragg = false;hideBar(); - $doc.unbind('.slimscroll'); + $doc.off('.slimscroll'); }); return false; - }).bind("selectstart.slimscroll", function(e){ + }).on("selectstart.slimscroll", function(e){ e.stopPropagation(); e.preventDefault(); return false; @@ -245,31 +244,31 @@ } // on rail over - rail.hover(function(){ + rail.on("mouseenter", function(){ showBar(); - }, function(){ + }).on("mouseleave", function(){ hideBar(); }); // on bar over - bar.hover(function(){ + bar.on("mouseenter", function(){ isOverBar = true; - }, function(){ + }).on("mouseleave", function(){ isOverBar = false; }); // show on parent mouseover - me.hover(function(){ + me.on("mouseenter", function(){ isOverPanel = true; showBar(); hideBar(); - }, function(){ + }).on("mouseleave", function(){ isOverPanel = false; hideBar(); }); // support for mobile - me.bind('touchstart', function(e,b){ + me.on('touchstart', function(e,b){ if (e.originalEvent.touches.length) { // record where touch started @@ -277,7 +276,7 @@ } }); - me.bind('touchmove', function(e){ + me.on('touchmove', function(e){ // prevent scrolling the page if necessary if(!releaseScroll) { @@ -417,7 +416,7 @@ clearTimeout(queueHide); // when bar reached top or bottom - if (percentScroll == ~~percentScroll) + if (Math.min(percentScroll, 1) == ~~percentScroll) { //release wheel releaseScroll = o.allowPageScroll; diff --git a/jquery.slimscroll.min.js b/jquery.slimscroll.min.js index 7531ab3..92c28f8 100644 --- a/jquery.slimscroll.min.js +++ b/jquery.slimscroll.min.js @@ -1,16 +1 @@ -/*! Copyright (c) 2011 Piotr Rochala (http://rocha.la) - * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. - * - * Version: 1.3.8 - * - */ -(function(e){e.fn.extend({slimScroll:function(f){var a=e.extend({width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},f);this.each(function(){function v(d){if(r){d=d||window.event; -var c=0;d.wheelDelta&&(c=-d.wheelDelta/120);d.detail&&(c=d.detail/3);e(d.target||d.srcTarget||d.srcElement).closest("."+a.wrapperClass).is(b.parent())&&n(c,!0);d.preventDefault&&!k&&d.preventDefault();k||(d.returnValue=!1)}}function n(d,g,e){k=!1;var f=b.outerHeight()-c.outerHeight();g&&(g=parseInt(c.css("top"))+d*parseInt(a.wheelStep)/100*c.outerHeight(),g=Math.min(Math.max(g,0),f),g=0=b.outerHeight()?k=!0:(c.stop(!0, -!0).fadeIn("fast"),a.railVisible&&m.stop(!0,!0).fadeIn("fast"))}function p(){a.alwaysVisible||(B=setTimeout(function(){a.disableFadeOut&&r||y||z||(c.fadeOut("slow"),m.fadeOut("slow"))},1E3))}var r,y,z,B,A,u,l,C,k=!1,b=e(this);if(b.parent().hasClass(a.wrapperClass)){var q=b.scrollTop(),c=b.siblings("."+a.barClass),m=b.siblings("."+a.railClass);x();if(e.isPlainObject(f)){if("height"in f&&"auto"==f.height){b.parent().css("height","auto");b.css("height","auto");var h=b.parent().parent().height();b.parent().css("height", -h);b.css("height",h)}else"height"in f&&(h=f.height,b.parent().css("height",h),b.css("height",h));if("scrollTo"in f)q=parseInt(a.scrollTo);else if("scrollBy"in f)q+=parseInt(a.scrollBy);else if("destroy"in f){c.remove();m.remove();b.unwrap();return}n(q,!1,!0)}}else if(!(e.isPlainObject(f)&&"destroy"in f)){a.height="auto"==a.height?b.parent().height():a.height;q=e("
").addClass(a.wrapperClass).css({position:"relative",overflow:"hidden",width:a.width,height:a.height});b.css({overflow:"hidden", -width:a.width,height:a.height});var m=e("
").addClass(a.railClass).css({width:a.size,height:"100%",position:"absolute",top:0,display:a.alwaysVisible&&a.railVisible?"block":"none","border-radius":a.railBorderRadius,background:a.railColor,opacity:a.railOpacity,zIndex:90}),c=e("
").addClass(a.barClass).css({background:a.color,width:a.size,position:"absolute",top:0,opacity:a.opacity,display:a.alwaysVisible?"block":"none","border-radius":a.borderRadius,BorderRadius:a.borderRadius,MozBorderRadius:a.borderRadius, -WebkitBorderRadius:a.borderRadius,zIndex:99}),h="right"==a.position?{right:a.distance}:{left:a.distance};m.css(h);c.css(h);b.wrap(q);b.parent().append(c);b.parent().append(m);a.railDraggable&&c.bind("mousedown",function(a){var b=e(document);z=!0;t=parseFloat(c.css("top"));pageY=a.pageY;b.bind("mousemove.slimscroll",function(a){currTop=t+a.pageY-pageY;c.css("top",currTop);n(0,c.position().top,!1)});b.bind("mouseup.slimscroll",function(a){z=!1;p();b.unbind(".slimscroll")});return!1}).bind("selectstart.slimscroll", -function(a){a.stopPropagation();a.preventDefault();return!1});m.hover(function(){w()},function(){p()});c.hover(function(){y=!0},function(){y=!1});b.hover(function(){r=!0;w();p()},function(){r=!1;p()});b.bind("touchstart",function(a,b){a.originalEvent.touches.length&&(A=a.originalEvent.touches[0].pageY)});b.bind("touchmove",function(b){k||b.originalEvent.preventDefault();b.originalEvent.touches.length&&(n((A-b.originalEvent.touches[0].pageY)/a.touchScrollStep,!0),A=b.originalEvent.touches[0].pageY)}); -x();"bottom"===a.start?(c.css({top:b.outerHeight()-c.outerHeight()}),n(0,!0)):"top"!==a.start&&(n(e(a.start).position().top,null,!0),a.alwaysVisible||c.hide());window.addEventListener?(this.addEventListener("DOMMouseScroll",v,!1),this.addEventListener("mousewheel",v,!1)):document.attachEvent("onmousewheel",v)}});return this}});e.fn.extend({slimscroll:e.fn.slimScroll})})(jQuery); \ No newline at end of file +(function(e){e.fn.extend({slimScroll:function(i){var o={width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},s=e.extend(o,i);return this.each(function(){function o(t){if(h){var t=t||window.event,i=0;t.wheelDelta&&(i=-t.wheelDelta/120),t.detail&&(i=t.detail/3);var o=t.target||t.srcTarget||t.srcElement;e(o).closest("."+s.wrapperClass).is(x.parent())&&a(i,!0),t.preventDefault&&!y&&t.preventDefault(),y||(t.returnValue=!1)}}function a(e,t,i){y=!1;var o=e,a=x.outerHeight()-R.outerHeight();if(t&&(o=parseInt(R.css("top"))+e*parseInt(s.wheelStep)/100*R.outerHeight(),o=Math.min(Math.max(o,0),a),o=e>0?Math.ceil(o):Math.floor(o),R.css({top:o+"px"})),v=parseInt(R.css("top"))/(x.outerHeight()-R.outerHeight()),o=v*(x[0].scrollHeight-x.outerHeight()),i){o=e;var r=o/x[0].scrollHeight*x.outerHeight();r=Math.min(Math.max(r,0),a),R.css({top:r+"px"})}x.scrollTop(o),x.trigger("slimscrolling",~~o),n(),c()}function r(e){window.addEventListener?(e.addEventListener("DOMMouseScroll",o,!1),e.addEventListener("mousewheel",o,!1)):document.attachEvent("onmousewheel",o)}function l(){f=Math.max(x.outerHeight()/x[0].scrollHeight*x.outerHeight(),w),R.css({height:f+"px"});var e=f==x.outerHeight()?"none":"block";R.css({display:e})}function n(){if(l(),clearTimeout(d),Math.min(v,1)==~~v){if(y=s.allowPageScroll,m!=v){var e=0==~~v?"top":"bottom";x.trigger("slimscroll",e)}}else y=!1;return m=v,f>=x.outerHeight()?void(y=!0):(R.stop(!0,!0).fadeIn("fast"),void(s.railVisible&&M.stop(!0,!0).fadeIn("fast")))}function c(){s.alwaysVisible||(d=setTimeout(function(){s.disableFadeOut&&h||u||p||(R.fadeOut("slow"),M.fadeOut("slow"))},1e3))}var h,u,p,d,g,f,v,m,b="
",w=30,y=!1,x=e(this);if(x.parent().hasClass(s.wrapperClass)){var C=x.scrollTop();if(R=x.siblings("."+s.barClass),M=x.siblings("."+s.railClass),l(),e.isPlainObject(i)){if("height"in i&&"auto"==i.height){x.parent().css("height","auto"),x.css("height","auto");var H=x.parent().parent().height();x.parent().css("height",H),x.css("height",H)}else if("height"in i){var S=i.height;x.parent().css("height",S),x.css("height",S)}if("scrollTo"in i)C=parseInt(s.scrollTo);else if("scrollBy"in i)C+=parseInt(s.scrollBy);else if("destroy"in i)return R.remove(),M.remove(),void x.unwrap();a(C,!1,!0)}}else if(!(e.isPlainObject(i)&&"destroy"in i)){s.height="auto"==s.height?x.parent().height():s.height;var E=e(b).addClass(s.wrapperClass).css({position:"relative",overflow:"hidden",width:s.width,height:s.height});x.css({overflow:"hidden",width:s.width,height:s.height});var M=e(b).addClass(s.railClass).css({width:s.size,height:"100%",position:"absolute",top:0,display:s.alwaysVisible&&s.railVisible?"block":"none","border-radius":s.railBorderRadius,background:s.railColor,opacity:s.railOpacity,zIndex:90}),R=e(b).addClass(s.barClass).css({background:s.color,width:s.size,position:"absolute",top:0,opacity:s.opacity,display:s.alwaysVisible?"block":"none","border-radius":s.borderRadius,BorderRadius:s.borderRadius,MozBorderRadius:s.borderRadius,WebkitBorderRadius:s.borderRadius,zIndex:99}),D="right"==s.position?{right:s.distance}:{left:s.distance};M.css(D),R.css(D),x.wrap(E),x.parent().append(R),x.parent().append(M),s.railDraggable&&R.on("mousedown",function(i){var o=e(document);return p=!0,t=parseFloat(R.css("top")),pageY=i.pageY,o.on("mousemove.slimscroll",function(e){currTop=t+e.pageY-pageY,R.css("top",currTop),a(0,R.position().top,!1)}),o.on("mouseup.slimscroll",function(e){p=!1,c(),o.off(".slimscroll")}),!1}).on("selectstart.slimscroll",function(e){return e.stopPropagation(),e.preventDefault(),!1}),M.on("mouseenter",function(){n()}).on("mouseleave",function(){c()}),R.on("mouseenter",function(){u=!0}).on("mouseleave",function(){u=!1}),x.on("mouseenter",function(){h=!0,n(),c()}).on("mouseleave",function(){h=!1,c()}),x.on("touchstart",function(e,t){e.originalEvent.touches.length&&(g=e.originalEvent.touches[0].pageY)}),x.on("touchmove",function(e){if(y||e.originalEvent.preventDefault(),e.originalEvent.touches.length){var t=(g-e.originalEvent.touches[0].pageY)/s.touchScrollStep;a(t,!0),g=e.originalEvent.touches[0].pageY}}),l(),"bottom"===s.start?(R.css({top:x.outerHeight()-R.outerHeight()}),a(0,!0)):"top"!==s.start&&(a(e(s.start).position().top,null,!0),s.alwaysVisible||R.hide()),r(this)}}),this}}),e.fn.extend({slimscroll:e.fn.slimScroll})})(jQuery); \ No newline at end of file From 642b792dee8b2b218b123775ced61fb1f592da86 Mon Sep 17 00:00:00 2001 From: Tim Shilov Date: Tue, 22 Jan 2019 13:23:45 +0300 Subject: [PATCH 2/2] 1.3.9 --- package.json | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 147e92d..cc3649f 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,33 @@ { - "name" : "jquery-slimscroll", - "main" : "jquery.slimscroll.js", - "version" : "1.3.8", - "title" : "jQuery slimScroll scrollbar", - "description" : "slimScroll is a small jQuery plugin that transforms any div into a scrollable area. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over.", - "keywords" : ["scrollbar", "scroll", "slimscroll", "scrollable", "scrolling", "scroller", "ui", "jquery-plugin", "ecosystem:jquery"], - "homepage" : "http://rocha.la/jQuery-slimScroll/", + "name": "jquery-slimscroll", + "main": "jquery.slimscroll.js", + "version": "1.3.9", + "title": "jQuery slimScroll scrollbar", + "description": "slimScroll is a small jQuery plugin that transforms any div into a scrollable area. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over.", + "keywords": [ + "scrollbar", + "scroll", + "slimscroll", + "scrollable", + "scrolling", + "scroller", + "ui", + "jquery-plugin", + "ecosystem:jquery" + ], + "homepage": "http://rocha.la/jQuery-slimScroll/", "repository": { "type": "git", "url": "https://github.com/rochal/jQuery-slimScroll.git" }, - "author" : { - "name" : "Piotr Rochala", - "url" : "http://rocha.la/" + "author": { + "name": "Piotr Rochala", + "url": "http://rocha.la/" }, - - "dependencies" : { - "jquery" : ">= 1.7" + "dependencies": { + "jquery": ">= 1.7" }, - - "licenses" : [ + "licenses": [ { "type": "MIT", "url": "http://www.opensource.org/licenses/mit-license.php" @@ -29,4 +37,4 @@ "url": "http://www.opensource.org/licenses/gpl-license.php" } ] -} \ No newline at end of file +}