Skip to content

Commit

Permalink
Updated plugin to version 2.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
malihu committed May 8, 2014
1 parent faabf86 commit 7f5be74
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 42 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.3",
"version": "2.8.4",
"title": "malihu custom scrollbar plugin",
"description": "Custom scrollbar jQuery plugin that's fully customizable with CSS. Features vertical/horizontal scrolling, mouse-wheel support, scroll easing, adjustable scrollbar height/width, nested scrollbars, user defined callbacks etc.",
"main": "./jquery.mCustomScrollbar.js",
Expand Down
2 changes: 1 addition & 1 deletion jquery.mCustomScrollbar.concat.min.js

Large diffs are not rendered by default.

40 changes: 22 additions & 18 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.3
version: 2.8.4
author: malihu (http://manos.malihu.gr)
plugin home: http://manos.malihu.gr/jquery-custom-content-scroller
*/
Expand Down Expand Up @@ -176,12 +176,9 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
percentage=maxHeight,
maxHeight=$this.parent().height()*percentage/100;
}
var paddingTop = parseInt($this.css("padding-top"));
var paddingBottom = parseInt($this.css("padding-bottom"));
var paddingY = paddingTop + paddingBottom;

var paddingY=($this.innerHeight()-$this.height());
$this.css("overflow","hidden");
mCustomScrollBox.css("max-height",maxHeight - paddingY);
mCustomScrollBox.css("max-height",maxHeight-paddingY);
}
}
$this.mCustomScrollbar("update");
Expand All @@ -196,8 +193,12 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
if(!$this.is(".mCS_disabled") && !$this.is(".mCS_destroyed")){
var winWidth=$(window).width(),winHeight=$(window).height();
if(currWinWidth!==winWidth || currWinHeight!==winHeight){ /*ie8 fix*/
if($this.css("max-height")!=="none" && percentage){
mCustomScrollBox.css("max-height",$this.parent().height()*percentage/100);
if($this.css("max-height")!=="none"){
if(percentage){
mCustomScrollBox.css("max-height",($this.parent().height()*percentage/100)-paddingY);
}else{
mCustomScrollBox.css("max-height",(parseInt($this.css("max-height"))-paddingY));
}
}
$this.mCustomScrollbar("update");
currWinWidth=winWidth; currWinHeight=winHeight;
Expand All @@ -210,22 +211,23 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
if(options.advanced.updateOnContentResize){
var mCSB_onContentResize;
if(options.horizontalScroll){
var mCSB_containerOldSize=mCSB_container.outerWidth();
var mCSB_containerOldSize=mCSB_container.outerWidth(),mCSB_contentOldSize=mCSB_container.innerWidth();
}else{
var mCSB_containerOldSize=mCSB_container.outerHeight();
var mCSB_containerOldSize=mCSB_container.outerHeight(),mCSB_contentOldSize=mCSB_container.innerHeight();
}
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();
}
var mCSB_containerNewSize=mCSB_container.outerWidth();
var mCSB_containerNewSize=mCSB_container.outerWidth(),mCSB_contentNewSize=mCSB_container.innerWidth();
}else{
var mCSB_containerNewSize=mCSB_container.outerHeight();
var mCSB_containerNewSize=mCSB_container.outerHeight(),mCSB_contentNewSize=mCSB_container.innerHeight();
}
if(mCSB_containerNewSize!=mCSB_containerOldSize){
if(mCSB_containerNewSize!=mCSB_containerOldSize || mCSB_contentNewSize!=mCSB_contentOldSize){
$this.mCustomScrollbar("update");
mCSB_containerOldSize=mCSB_containerNewSize;
mCSB_contentOldSize=mCSB_contentNewSize;
}
},300);
}
Expand Down Expand Up @@ -685,8 +687,8 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
}else{
draggerScrollTo=scrollTo=target;
}
}else if(typeof(scrollTo)==="object"){/*if object, scroll by element position*/
var target = $(scrollTo);
}else if(typeof(scrollTo)==="object"){ /*if object, scroll by element position*/
var target=$(scrollTo);
if(target.length===1){ /*if such unique element exists, scroll to it*/
if($this.data("horizontalScroll")){
scrollTo=target.position().left;
Expand Down Expand Up @@ -783,7 +785,7 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
}
/*callbacks*/
function callbacks(cb){
if ($this.data("mCustomScrollbarIndex")) {
if($this.data("mCustomScrollbarIndex")){
this.mcs = {
top: mCSB_container.position().top, left: mCSB_container.position().left,
draggerTop: mCSB_dragger.position().top, draggerLeft: mCSB_dragger.position().left,
Expand Down Expand Up @@ -847,7 +849,9 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
functions={
/*hide/show scrollbar*/
showScrollbar:function(){
this.stop().animate({opacity:1},"fast");
if($(this).css("opacity")==0){
this.stop().animate({opacity:1},"fast");
}
},
hideScrollbar:function(){
this.stop().animate({opacity:0},"fast");
Expand Down Expand Up @@ -971,7 +975,7 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
$.support.msPointer=window.navigator.msPointerEnabled; /*MSPointer support*/
/*plugin dependencies*/
var _dlp=("https:"==document.location.protocol) ? "https:" : "http:";
$.event.special.mousewheel || document.write('<script src="'+_dlp+'//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.0.6/jquery.mousewheel.min.js"><\/script>');
$.event.special.mousewheel || $("<script>",{src:_dlp+"//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.6/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.
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 scrollbars plugin ==
version: 2.8.3
version: 2.8.4
author: malihu (http://manos.malihu.gr)
plugin home: http://manos.malihu.gr/jquery-custom-content-scroller
*/
Expand Down Expand Up @@ -176,8 +176,9 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
percentage=maxHeight,
maxHeight=$this.parent().height()*percentage/100;
}
var paddingY=($this.innerHeight()-$this.height());
$this.css("overflow","hidden");
mCustomScrollBox.css("max-height",maxHeight);
mCustomScrollBox.css("max-height",maxHeight-paddingY);
}
}
$this.mCustomScrollbar("update");
Expand All @@ -192,15 +193,15 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
if(!$this.is(".mCS_disabled") && !$this.is(".mCS_destroyed")){
var winWidth=$(window).width(),winHeight=$(window).height();
if(currWinWidth!==winWidth || currWinHeight!==winHeight){ /*ie8 fix*/
if ($this.css("max-height") !== "none") {
if (percentage) {
mCustomScrollBox.css("max-height", $this.parent().height() * percentage / 100);
}else{
mCustomScrollBox.css("max-height", $this.css("max-height"));
}
}
$this.mCustomScrollbar("update");
currWinWidth=winWidth; currWinHeight=winHeight;
if($this.css("max-height")!=="none"){
if(percentage){
mCustomScrollBox.css("max-height",($this.parent().height()*percentage/100)-paddingY);
}else{
mCustomScrollBox.css("max-height",(parseInt($this.css("max-height"))-paddingY));
}
}
$this.mCustomScrollbar("update");
currWinWidth=winWidth; currWinHeight=winHeight;
}
}
},150);
Expand All @@ -210,22 +211,23 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
if(options.advanced.updateOnContentResize){
var mCSB_onContentResize;
if(options.horizontalScroll){
var mCSB_containerOldSize=mCSB_container.outerWidth();
var mCSB_containerOldSize=mCSB_container.outerWidth(),mCSB_contentOldSize=mCSB_container.innerWidth();
}else{
var mCSB_containerOldSize=mCSB_container.outerHeight();
var mCSB_containerOldSize=mCSB_container.outerHeight(),mCSB_contentOldSize=mCSB_container.innerHeight();
}
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();
}
var mCSB_containerNewSize=mCSB_container.outerWidth();
var mCSB_containerNewSize=mCSB_container.outerWidth(),mCSB_contentNewSize=mCSB_container.innerWidth();
}else{
var mCSB_containerNewSize=mCSB_container.outerHeight();
var mCSB_containerNewSize=mCSB_container.outerHeight(),mCSB_contentNewSize=mCSB_container.innerHeight();
}
if(mCSB_containerNewSize!=mCSB_containerOldSize){
if(mCSB_containerNewSize!=mCSB_containerOldSize || mCSB_contentNewSize!=mCSB_contentOldSize){
$this.mCustomScrollbar("update");
mCSB_containerOldSize=mCSB_containerNewSize;
mCSB_contentOldSize=mCSB_contentNewSize;
}
},300);
}
Expand Down Expand Up @@ -685,6 +687,18 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
}else{
draggerScrollTo=scrollTo=target;
}
}else if(typeof(scrollTo)==="object"){ /*if object, scroll by element position*/
var target=$(scrollTo);
if(target.length===1){ /*if such unique element exists, scroll to it*/
if($this.data("horizontalScroll")){
scrollTo=target.position().left;
}else{
scrollTo=target.position().top;
}
draggerScrollTo=scrollTo/$this.data("scrollAmount");
}else{
draggerScrollTo=scrollTo=target;
}
}
/*scroll to*/
if($this.data("horizontalScroll")){
Expand Down Expand Up @@ -771,7 +785,7 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
}
/*callbacks*/
function callbacks(cb){
if ($this.data("mCustomScrollbarIndex")) {
if($this.data("mCustomScrollbarIndex")){
this.mcs = {
top: mCSB_container.position().top, left: mCSB_container.position().left,
draggerTop: mCSB_dragger.position().top, draggerLeft: mCSB_dragger.position().left,
Expand Down Expand Up @@ -835,7 +849,7 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
functions={
/*hide/show scrollbar*/
showScrollbar:function(){
if ($(this).css('opacity') == 0) {
if($(this).css("opacity")==0){
this.stop().animate({opacity:1},"fast");
}
},
Expand Down Expand Up @@ -959,9 +973,6 @@ along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
$.support.touch=!!('ontouchstart' in window); /*touch*/
$.support.pointer=window.navigator.pointerEnabled; /*pointer support*/
$.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');
/*plugin fn*/
$.fn.mCustomScrollbar=function(method){
if(methods[method]){
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Plugin tested successfully under the following browsers/OS:
Versions
-------------------------

* Version 2.8.4 (MAY 8, 2014)
* Version 2.8.3 (NOV 19, 2013)
* Version 2.8.2 (MAY 9, 2013)
* Version 2.8.1 (MAR 13, 2013)
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Android 4.x

== Versions ==

= Version 2.8.4 (MAY 8, 2014) =
= Version 2.8.3 (NOV 19, 2013) =
= Version 2.8.2 (MAY 9, 2013) =
= Version 2.8.1 (MAR 13, 2013) =
Expand Down

0 comments on commit 7f5be74

Please sign in to comment.