From afff98803fe88c189a47ca09145a41db5b9501ed Mon Sep 17 00:00:00 2001 From: Sir Francis Drake <32283384+bf-cortex@users.noreply.github.com> Date: Fri, 5 Oct 2018 04:17:52 +0200 Subject: [PATCH 1/4] Update jquery.slimscroll.js --- jquery.slimscroll.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jquery.slimscroll.js b/jquery.slimscroll.js index 90caed3..124eaa5 100644 --- a/jquery.slimscroll.js +++ b/jquery.slimscroll.js @@ -2,7 +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.4.0 * */ (function($) { @@ -76,7 +76,10 @@ borderRadius: '7px', // sets border radius of the rail - railBorderRadius : '7px' + railBorderRadius : '7px', + + // sets offset of the scrollbar + offset: 0 }; var o = $.extend(defaults, options); @@ -300,7 +303,7 @@ if (o.start === 'bottom') { // scroll content to bottom - bar.css({ top: me.outerHeight() - bar.outerHeight() }); + bar.css({ top: me.outerHeight() - (bar.outerHeight() + o.offset) }); scrollContent(0, true); } else if (o.start !== 'top') @@ -341,12 +344,12 @@ { releaseScroll = false; var delta = y; - var maxTop = me.outerHeight() - bar.outerHeight(); + var maxTop = me.outerHeight() - (bar.outerHeight() + o.offset); if (isWheel) { // move bar with mouse wheel - delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight(); + delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * (bar.outerHeight() + o.offset); // move bar, make sure it doesn't go out delta = Math.min(Math.max(delta, 0), maxTop); @@ -362,7 +365,7 @@ } // calculate actual scroll amount - percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight()); + percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - (bar.outerHeight() + o.offset)); delta = percentScroll * (me[0].scrollHeight - me.outerHeight()); if (isJump) @@ -403,7 +406,7 @@ { // calculate scrollbar height and make sure it is not too small barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight); - bar.css({ height: barHeight + 'px' }); + bar.css({ height: (barHeight - o.offset) + 'px' }); // hide scrollbar if content is not long enough var display = barHeight == me.outerHeight() ? 'none' : 'block'; From c6257ea0cf01e83a17e6edd564699a07b24015f3 Mon Sep 17 00:00:00 2001 From: Sir Francis Drake <32283384+bf-cortex@users.noreply.github.com> Date: Fri, 5 Oct 2018 04:19:40 +0200 Subject: [PATCH 2/4] Update jquery.slimscroll.min.js --- jquery.slimscroll.min.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/jquery.slimscroll.min.js b/jquery.slimscroll.min.js index 7531ab3..f845485 100644 --- a/jquery.slimscroll.min.js +++ b/jquery.slimscroll.min.js @@ -2,15 +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.4.0 * */ -(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(M){M.fn.extend({slimScroll:function(R){var D=M.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",offset:0},R);return this.each(function(){var s,e,o,i,a,r,l,n,c="
",h=30,u=!1,p=M(this);if(p.parent().hasClass(D.wrapperClass)){var d=p.scrollTop();if(m=p.siblings("."+D.barClass),w=p.siblings("."+D.railClass),H(),M.isPlainObject(R)){if("height"in R&&"auto"==R.height){p.parent().css("height","auto"),p.css("height","auto");var g=p.parent().parent().height();p.parent().css("height",g),p.css("height",g)}else if("height"in R){var f=R.height;p.parent().css("height",f),p.css("height",f)}if("scrollTo"in R)d=parseInt(D.scrollTo);else if("scrollBy"in R)d+=parseInt(D.scrollBy);else if("destroy"in R)return m.remove(),w.remove(),void p.unwrap();C(d,!1,!0)}}else if(!(M.isPlainObject(R)&&"destroy"in R)){D.height="auto"==D.height?p.parent().height():D.height;var b=M(c).addClass(D.wrapperClass).css({position:"relative",overflow:"hidden",width:D.width,height:D.height});p.css({overflow:"hidden",width:D.width,height:D.height});var v,w=M(c).addClass(D.railClass).css({width:D.size,height:"100%",position:"absolute",top:0,display:D.alwaysVisible&&D.railVisible?"block":"none","border-radius":D.railBorderRadius,background:D.railColor,opacity:D.railOpacity,zIndex:90}),m=M(c).addClass(D.barClass).css({background:D.color,width:D.size,position:"absolute",top:0,opacity:D.opacity,display:D.alwaysVisible?"block":"none","border-radius":D.borderRadius,BorderRadius:D.borderRadius,MozBorderRadius:D.borderRadius,WebkitBorderRadius:D.borderRadius,zIndex:99}),y="right"==D.position?{right:D.distance}:{left:D.distance};w.css(y),m.css(y),p.wrap(b),p.parent().append(m),p.parent().append(w),D.railDraggable&&m.bind("mousedown",function(e){var i=M(document);return o=!0,t=parseFloat(m.css("top")),pageY=e.pageY,i.bind("mousemove.slimscroll",function(e){currTop=t+e.pageY-pageY,m.css("top",currTop),C(0,m.position().top,!1)}),i.bind("mouseup.slimscroll",function(e){o=!1,E(),i.unbind(".slimscroll")}),!1}).bind("selectstart.slimscroll",function(e){return e.stopPropagation(),e.preventDefault(),!1}),w.hover(function(){S()},function(){E()}),m.hover(function(){e=!0},function(){e=!1}),p.hover(function(){s=!0,S(),E()},function(){s=!1,E()}),p.bind("touchstart",function(e,t){e.originalEvent.touches.length&&(a=e.originalEvent.touches[0].pageY)}),p.bind("touchmove",function(e){(u||e.originalEvent.preventDefault(),e.originalEvent.touches.length)&&(C((a-e.originalEvent.touches[0].pageY)/D.touchScrollStep,!0),a=e.originalEvent.touches[0].pageY)}),H(),"bottom"===D.start?(m.css({top:p.outerHeight()-(m.outerHeight()+D.offset)}),C(0,!0)):"top"!==D.start&&(C(M(D.start).position().top,null,!0),D.alwaysVisible||m.hide()),v=this,window.addEventListener?(v.addEventListener("DOMMouseScroll",x,!1),v.addEventListener("mousewheel",x,!1)):document.attachEvent("onmousewheel",x)}function x(e){if(s){var t=0;(e=e||window.event).wheelDelta&&(t=-e.wheelDelta/120),e.detail&&(t=e.detail/3);var i=e.target||e.srcTarget||e.srcElement;M(i).closest("."+D.wrapperClass).is(p.parent())&&C(t,!0),e.preventDefault&&!u&&e.preventDefault(),u||(e.returnValue=!1)}}function C(e,t,i){u=!1;var s=e,o=p.outerHeight()-(m.outerHeight()+D.offset);if(t&&(s=parseInt(m.css("top"))+e*parseInt(D.wheelStep)/100*(m.outerHeight()+D.offset),s=Math.min(Math.max(s,0),o),s=0=p.outerHeight()?u=!0:(m.stop(!0,!0).fadeIn("fast"),D.railVisible&&w.stop(!0,!0).fadeIn("fast"))}function E(){D.alwaysVisible||(i=setTimeout(function(){D.disableFadeOut&&s||e||o||(m.fadeOut("slow"),w.fadeOut("slow"))},1e3))}}),this}}),M.fn.extend({slimscroll:M.fn.slimScroll})}(jQuery); From 73c4ba004e8f2317960e3cb3d8a8f934bdd47919 Mon Sep 17 00:00:00 2001 From: Sir Francis Drake <32283384+bf-cortex@users.noreply.github.com> Date: Fri, 5 Oct 2018 04:21:48 +0200 Subject: [PATCH 3/4] Bump version to 1.4.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 147e92d..142614f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "jquery-slimscroll", "main" : "jquery.slimscroll.js", - "version" : "1.3.8", + "version" : "1.4.0", "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"], @@ -29,4 +29,4 @@ "url": "http://www.opensource.org/licenses/gpl-license.php" } ] -} \ No newline at end of file +} From f4758d0f9feeede12047fad2b58cb4272a9534f1 Mon Sep 17 00:00:00 2001 From: Sir Francis Drake <32283384+bf-cortex@users.noreply.github.com> Date: Fri, 5 Oct 2018 04:22:40 +0200 Subject: [PATCH 4/4] Bump version to 1.4.0 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 831eb32..ac23720 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-slimscroll", - "version": "1.3.8", + "version": "1.4.0", "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",