jQuery custom content scroller
Highly customizable custom scrollbar jQuery plugin. Features include vertical and/or horizontal scrollbar(s), adjustable scrolling momentum, mouse-wheel (via jQuery mousewheel plugin), keyboard and touch support, ready-to-use themes and customization via CSS, RTL direction support, option parameters for full control of scrollbar functionality, methods for triggering actions like scroll-to, update, destroy etc., user-defined callbacks and more.
Current version 3.1.5 (Changelog)
Upgrading from version 2
How to use it
Get started by downloading the archive which contains the plugin files (and a large amount of HTML demos and examples). Extract and upload jquery.mCustomScrollbar.concat.min.js, jquery.mCustomScrollbar.css and mCSB_buttons.png to your web server (alternatively you can load plugin files from a CDN).
HTML
Include jquery.mCustomScrollbar.css in the head tag your HTML document (more info)
<link rel="stylesheet" href="/path/to/jquery.mCustomScrollbar.css" />
Include jQuery library (if your project doesn’t use it already) and jquery.mCustomScrollbar.concat.min.js in the head tag or at the very bottom of your document, just before the closing body tag
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="/path/to/jquery.mCustomScrollbar.concat.min.js"></script>
CSS
The element(s) you want to add scrollbar(s) should have the typical CSS properties of an overflowed block which are a height (or max-height) value, an overflow value of auto (or hidden) and content long enough to require scrolling. For horizontal scrollbar, the element should have a width (or max-width) value set.
If you prefer to set your element’s height/width via javascript, you can use the setHeight
/setWidth
option parameters.
Initialization
Initialize via javascript
After files inclusion, call mCustomScrollbar function on the element selector you want to add the scrollbar(s)
<script> (function($){ $(window).on("load",function(){ $(".content").mCustomScrollbar(); }); })(jQuery); </script>
Initialize via HTML
Add the class mCustomScrollbar
to any element you want to add custom scrollbar(s) with default options. Optionally, set its axis via the HTML data attribute data-mcs-axis
(e.g. "x"
for horizontal and "y"
for vertical) and its theme via data-mcs-theme
. For example:
<div class="mCustomScrollbar" data-mcs-theme="dark"> <!-- your content --> </div>
Basic configuration & option parameters
axis
By default, the script applies a vertical scrollbar. To add a horizontal or 2-axis scrollbars, invoke mCustomScrollbar function with the axis option set to "x"
or "yx"
respectively
$(".content").mCustomScrollbar({ axis:"x" // horizontal scrollbar });
$(".content").mCustomScrollbar({ axis:"yx" // vertical and horizontal scrollbar });
theme
To quickly change the appearance of the scrollbar, set the theme option parameter to any of the ready-to-use themes available in jquery.mCustomScrollbar.css, for example:
$(".content").mCustomScrollbar({ theme:"dark" });
Configuration
You can configure your scrollbar(s) using the following option parameters on mCustomScrollbar function
Usage $(selector).mCustomScrollbar({ option: value });
setWidth: false
- Set the width of your content (overwrites CSS width), value in pixels (integer) or percentage (string).
setHeight: false
- Set the height of your content (overwrites CSS height), value in pixels (integer) or percentage (string).
setTop: 0
- Set the initial css top property of content, accepts string values (css top position).
Example:setTop: "-100px"
.
setLeft: 0
- Set the initial css left property of content, accepts string values (css left position).
Example:setLeft: "-100px"
.
axis: "string"
- Define content’s scrolling axis (the type of scrollbars added to the element: vertical and/of horizontal).
Available values:"y"
,"x"
,"yx"
.axis: "y"
– vertical scrollbar (default)axis: "x"
– horizontal scrollbaraxis: "yx"
– vertical and horizontal scrollbars
scrollbarPosition: "string"
- Set the position of scrollbar in relation to content.
Available values:"inside"
,"outside"
.
SettingscrollbarPosition: "inside"
(default) makes scrollbar appear inside the element. SettingscrollbarPosition: "outside"
makes scrollbar appear outside the element. Note that setting the value to"outside"
requires your element (or parent elements) to have CSSposition: relative
(otherwise the scrollbar will be positioned in relation to document’s root element).
scrollInertia: integer
- Set the amount of scrolling momentum as animation duration in milliseconds.
Higher value equals greater scrolling momentum which translates to smoother/more progressive animation. Set to0
to disable.
autoDraggerLength: boolean
- Enable or disable auto-adjusting scrollbar dragger length in relation to scrolling amount (same bahavior with browser’s native scrollbar).
SetautoDraggerLength: false
when you want your scrollbar to (always) have a fixed size.
autoHideScrollbar: boolean
- Enable or disable auto-hiding the scrollbar when inactive.
SettingautoHideScrollbar: true
will hide the scrollbar(s) when scrolling is idle and/or cursor is out of the scrolling area.
Please note that some special themes like “minimal” overwrite this option.
autoExpandScrollbar: boolean
- Enable or disable auto-expanding the scrollbar when cursor is over or dragging the scrollbar.
alwaysShowScrollbar: integer
- Always keep scrollbar(s) visible, even when there’s nothing to scroll.
alwaysShowScrollbar: 0
– disable (default)alwaysShowScrollbar: 1
– keep dragger rail visiblealwaysShowScrollbar: 2
– keep all scrollbar components (dragger, rail, buttons etc.) visible
snapAmount: integer
- Make scrolling snap to a multiple of a fixed number of pixels. Useful in cases like scrolling tabular data, image thumbnails or slides and you need to prevent scrolling from stopping half-way your elements. Note that your elements must be of equal width or height in order for this to work properly.
To set different values for vertical and horizontal scrolling, use an array:[y,x]
snapOffset: integer
- Set an offset (in pixels) for the snapAmount option. Useful when for example you need to offset the snap amount of table rows by the table header.
mouseWheel:{ enable: boolean }
- Enable or disable content scrolling via mouse-wheel.
mouseWheel:{ scrollAmount: integer }
- Set the mouse-wheel scrolling amount (in pixels). The default value
"auto"
adjusts scrolling amount according to scrollable content length.
mouseWheel:{ axis: "string" }
- Define the mouse-wheel scrolling axis when both vertical and horizontal scrollbars are present.
Setaxis: "y"
(default) for vertical oraxis: "x"
for horizontal scrolling.
mouseWheel:{ preventDefault: boolean }
- Prevent the default behaviour which automatically scrolls the parent element when end or beginning of scrolling is reached (same bahavior with browser’s native scrollbar).
mouseWheel:{ deltaFactor: integer }
- Set the number of pixels one wheel notch scrolls. The default value “auto” uses the OS/browser value.
mouseWheel:{ normalizeDelta: boolean }
- Enable or disable mouse-wheel (delta) acceleration. Setting
normalizeDelta: true
translates mouse-wheel delta value to -1 or 1.
mouseWheel:{ invert: boolean }
- Invert mouse-wheel scrolling direction. Set to
true
to scroll down or right when mouse-wheel is turned upwards.
mouseWheel:{ disableOver: [array] }
- Set the tags that disable mouse-wheel when cursor is over them.
Default value:["select","option","keygen","datalist","textarea"]
scrollButtons:{ enable: boolean }
- Enable or disable scrollbar buttons.
scrollButtons:{ scrollAmount: integer }
- Set the buttons scrolling amount (in pixels). The default value
"auto"
adjusts scrolling amount according to scrollable content length.
scrollButtons:{ scrollType: "string" }
- Define the buttons scrolling type/behavior.
scrollType: "stepless"
– continuously scroll content while pressing the button (default)scrollType: "stepped"
– each button click scrolls content by a certain amount (defined in scrollAmount option above)
scrollButtons:{ tabindex: integer }
- Set a tabindex value for the buttons.
keyboard:{ enable: boolean }
- Enable or disable content scrolling via the keyboard.
The plugin supports the directional arrows (top, left, right and down), page-up (PgUp), page-down (PgDn), Home and End keys.
keyboard:{ scrollAmount: integer }
- Set the keyboard arrows scrolling amount (in pixels). The default value
"auto"
adjusts scrolling amount according to scrollable content length.
keyboard:{ scrollType: "string" }
- Define the keyboard arrows scrolling type/behavior.
scrollType: "stepless"
– continuously scroll content while pressing the arrow key (default)scrollType: "stepped"
– each key release scrolls content by a certain amount (defined in scrollAmount option above)
contentTouchScroll: integer
- Enable or disable content touch-swipe scrolling for touch-enabled devices.
To completely disable, setcontentTouchScroll: false
.
Integer values define the axis-specific minimum amount required for scrolling momentum (default:25
).
documentTouchScroll: boolean
- Enable or disable document touch-swipe scrolling for touch-enabled devices.
advanced:{ autoExpandHorizontalScroll: boolean }
- Auto-expand content horizontally (for
"x"
or"yx"
axis).
If set totrue
, content will expand horizontally to accommodate any floated/inline-block elements.
Setting its value to2
(integer) forces the non scrollHeight/scrollWidth method. A value of3
forces the scrollHeight/scrollWidth method.
advanced:{ autoScrollOnFocus: "string" }
- Set the list of elements/selectors that will auto-scroll content to their position when focused.
For example, when pressing TAB key to focus input fields, if the field is out of the viewable area the content will scroll to its top/left position (same bahavior with browser’s native scrollbar).
To completely disable this functionality, setautoScrollOnFocus: false
.
Default:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']"
advanced:{ updateOnContentResize: boolean }
- Update scrollbar(s) automatically on content, element or viewport resize.
The value should betrue
(default) for fluid layouts/elements, adding/removing content dynamically, hiding/showing elements etc.
advanced:{ updateOnImageLoad: boolean }
- Update scrollbar(s) automatically each time an image inside the element is fully loaded.
Default value isauto
which triggers the function only on"x"
and"yx"
axis (if needed).
The value should betrue
when your content contains images and you need the function to trigger on any axis.
advanced:{ updateOnSelectorChange: "string" }
- Update scrollbar(s) automatically when the amount and size of specific selectors changes.
Useful when you need to update the scrollbar(s) automatically, each time a type of element is added, removed or changes its size.
For example, settingupdateOnSelectorChange: "ul li"
will update scrollbars each time list-items inside the element are changed.
Setting the value totrue
, will update scrollbars each time any element is changed.
To disable (default) set tofalse
.
advanced:{ extraDraggableSelectors: "string" }
- Add extra selector(s) that’ll release scrollbar dragging upon mouseup, pointerup, touchend etc.
Example:extraDraggableSelectors: ".myClass, #myID"
advanced:{ releaseDraggableSelectors: "string" }
- Add extra selector(s) that’ll allow scrollbar dragging upon mousemove/up, pointermove/up, touchend etc.
Example:releaseDraggableSelectors: ".myClass, #myID"
advanced:{ autoUpdateTimeout: integer }
- Set the auto-update timeout in milliseconds.
Default timeout:60
theme: "string"
- Set the scrollbar theme.
View all ready-to-use themes
All themes are contained in plugin’s CSS file (jquery.mCustomScrollbar.css).
Default theme:"light"
callbacks:{ onCreate: function(){} }
- A function to call when plugin markup is created.
Example:
callbacks:{ onCreate:function(){ console.log("Plugin markup generated"); } }
callbacks:{ onInit: function(){} }
- A function to call when scrollbars have initialized (demo).
Example:
callbacks:{ onInit:function(){ console.log("Scrollbars initialized"); } }
callbacks:{ onScrollStart: function(){} }
- A function to call when scrolling starts (demo).
Example:
callbacks:{ onScrollStart:function(){ console.log("Scrolling started..."); } }
callbacks:{ onScroll: function(){} }
- A function to call when scrolling is completed (demo).
Example:
callbacks:{ onScroll:function(){ console.log("Content scrolled..."); } }
callbacks:{ whileScrolling: function(){} }
- A function to call while scrolling is active (demo).
Example:
callbacks:{ whileScrolling:function(){ console.log("Scrolling..."); } }
callbacks:{ onTotalScroll: function(){} }
- A function to call when scrolling is completed and content is scrolled all the way to the end (bottom/right) (demo).
Example:
callbacks:{ onTotalScroll:function(){ console.log("Scrolled to end of content."); } }
callbacks:{ onTotalScrollBack: function(){} }
- A function to call when scrolling is completed and content is scrolled back to the beginning (top/left) (demo).
Example:
callbacks:{ onTotalScrollBack:function(){ console.log("Scrolled back to the beginning of content."); } }
callbacks:{ onTotalScrollOffset: integer }
- Set an offset for the onTotalScroll option.
For example, settingonTotalScrollOffset: 100
will trigger the onTotalScroll callback 100 pixels before the end of scrolling is reached.
callbacks:{ onTotalScrollBackOffset: integer }
- Set an offset for the onTotalScrollBack option.
For example, settingonTotalScrollBackOffset: 100
will trigger the onTotalScrollBack callback 100 pixels before the beginning of scrolling is reached.
callbacks:{ alwaysTriggerOffsets: boolean }
- Set the behavior of calling onTotalScroll and onTotalScrollBack offsets.
By default, callback offsets will trigger repeatedly while content is scrolling within the offsets.
SetalwaysTriggerOffsets: false
when you need to trigger onTotalScroll and onTotalScrollBack callbacks once, each time scroll end or beginning is reached.
callbacks:{ onOverflowY: function(){} }
- A function to call when content becomes long enough and vertical scrollbar is added.
Example:
callbacks:{ onOverflowY:function(){ console.log("Vertical scrolling required"); } }
callbacks:{ onOverflowX: function(){} }
- A function to call when content becomes wide enough and horizontal scrollbar is added.
Example:
callbacks:{ onOverflowX:function(){ console.log("Horizontal scrolling required"); } }
callbacks:{ onOverflowYNone: function(){} }
- A function to call when content becomes short enough and vertical scrollbar is removed.
Example:
callbacks:{ onOverflowYNone:function(){ console.log("Vertical scrolling is not required"); } }
callbacks:{ onOverflowXNone: function(){} }
- A function to call when content becomes narrow enough and horizontal scrollbar is removed.
Example:
callbacks:{ onOverflowXNone:function(){ console.log("Horizontal scrolling is not required"); } }
callbacks:{ onBeforeUpdate: function(){} }
- A function to call right before scrollbar(s) are updated.
Example:
callbacks:{ onBeforeUpdate:function(){ console.log("Scrollbars will update"); } }
callbacks:{ onUpdate: function(){} }
- A function to call when scrollbar(s) are updated.
Example:
callbacks:{ onUpdate:function(){ console.log("Scrollbars updated"); } }
callbacks:{ onImageLoad: function(){} }
- A function to call each time an image inside the element is fully loaded and scrollbar(s) are updated.
Example:
callbacks:{ onImageLoad:function(){ console.log("Image loaded"); } }
callbacks:{ onSelectorChange: function(){} }
- A function to call each time a type of element is added, removed or changes its size and scrollbar(s) are updated.
Example:
callbacks:{ onSelectorChange:function(){ console.log("Scrollbars updated"); } }
live: "string"
- Enable or disable applying scrollbar(s) on all elements matching the current selector, now and in the future.
Setlive: true
when you need to add scrollbar(s) on elements that do not yet exist in the page. These could be elements added by other scripts or plugins after some action by the user takes place (e.g. lightbox markup may not exist untill the user clicks a link).
If you need at any time to disable or enable the live option, setlive: "off"
and"on"
respectively.
You can also tell the script to disable live option after the first invocation by settinglive: "once"
.
liveSelector: "string"
- Set the matching set of elements (instead of the current selector) to add scrollbar(s), now and in the future.
Plugin methods
Ways to execute various plugin actions programmatically from within your script(s).
update
Usage $(selector).mCustomScrollbar("update");
Call the update method to manually update existing scrollbars to accommodate new content or resized element(s). This method is by default called automatically by the script (via updateOnContentResize
option) when the element itself, its content or scrollbar size changes.
scrollTo
Usage $(selector).mCustomScrollbar("scrollTo",position,options);
Call the scrollTo method to programmatically scroll the content to the position parameter (demo).
position parameter
Position parameter can be:
"string"
- e.g. element selector:
"#element-id"
- e.g. special pre-defined position:
"bottom"
- e.g. number of pixels less/more:
"-=100"
/"+=100"
- e.g. element selector:
integer
- e.g. number of pixels:
100
- e.g. number of pixels:
[array]
- e.g. different y/x position:
[100,50]
- e.g. different y/x position:
object/function
- e.g. jQuery object:
$("#element-id")
- e.g. js object:
document.getelementbyid("element-id")
- e.g. function:
function(){ return 100; }
- e.g. jQuery object:
Pre-defined position strings:
"bottom"
– scroll to bottom"top"
– scroll to top"right"
– scroll to right"left"
– scroll to left"first"
– scroll to the position of the first element within content"last"
– scroll to the position of the last element within content
Method options
scrollInertia: integer
- Scroll-to duration, value in milliseconds.
Example:
$(selector).mCustomScrollbar("scrollTo","bottom",{ scrollInertia:3000 });
scrollEasing: "string"
- Scroll-to animation easing, values:
"linear"
,"easeOut"
,"easeInOut"
.
Example:
$(selector).mCustomScrollbar("scrollTo","bottom",{ scrollEasing:"easeOut" });
moveDragger: boolean
- Scroll scrollbar dragger (instead of content).
Example:
$(selector).mCustomScrollbar("scrollTo",80,{ moveDragger:true });
timeout: integer
- Set a timeout for the method (the default timeout is 60 ms in order to work with automatic scrollbar update), value in milliseconds.
Example:
$(selector).mCustomScrollbar("scrollTo","top",{ timeout:1000 });
callbacks: boolean
- Trigger user defined callbacks after scroll-to completes.
Example:
$(selector).mCustomScrollbar("scrollTo","left",{ callbacks:false });
stop
Usage $(selector).mCustomScrollbar("stop");
Stops any running scrolling animations (usefull when you wish to interupt a previously scrollTo method call).
disable
Usage $(selector).mCustomScrollbar("disable");
Calling disable method will temporarily disable the scrollbar (demo). Disabled scrollbars can be re-enable by calling the update method.
To disable the scrollbar and reset its content position, set the method’s reset parameter to true
$(selector).mCustomScrollbar("disable",true);
destroy
Usage $(selector).mCustomScrollbar("destroy");
Calling destroy method will completely remove the custom scrollbar and return the element to its original state (demo).
Scrollbar styling & themes
You can design and visually customize your scrollbars with pure CSS, using jquery.mCustomScrollbar.css which contains the default/basic styling and all scrollbar themes.
The easiest/quickest way is to select a ready-to-use scrollbar theme. For example:
$(selector).mCustomScrollbar({ theme:"dark" });
You can modify the default styling or any theme either directly in jquery.mCustomScrollbar.css or by overwriting the CSS rules in another stylesheet.
Creating a new scrollbar theme
Create a name for your theme (e.g. “my-theme”) and set it as the value of the theme option
$(selector).mCustomScrollbar({ theme:"my-theme" });
Your element will get the class “mCS-my-theme” (your theme-name with “mCS” prefix), so you can create your CSS using the .mCS-my-theme
in your rules. For instance:
.mCS-my-theme.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar{ background-color: red; } .mCS-my-theme.mCSB_scrollTools .mCSB_draggerRail{ background-color: white; } /* and so on... */
In the same manner you can clone any existing theme (e.g. “dark”), change its selector (e.g. .mCS-dark
) to your own theme name (e.g. .mCS-my-theme
) and modify its CSS rules.
Scrollbar markup
The plugin applies specific id (unique) and/or classes to every scrollbar element/component, meaning that you can target and modify any scrollbar in more than one ways.
For example, every element with a scrollbar gets a unique class in the form of _mCS_1
, _mCS_2
etc. Every scrollbar container element gets a unique id in the form of mCSB_1_scrollbar_vertical
, mCSB_2_scrollbar_vertical
etc. Every scrollbar dragger gets a unique id in the form of mCSB_1_dragger_vertical
, mCSB_2_dragger_vertical
etc. in addition to the class mCSB_dragger
. All these mean that you can do stuff like:
._mCS_1 .mCSB_dragger .mCSB_dragger_bar{ background-color: red; } ._mCS_2 .mCSB_dragger .mCSB_dragger_bar{ background-color: green; } #mCSB_3_dragger_vertical .mCSB_dragger_bar{ background-color: blue; } #mCSB_1_scrollbar_vertical .mCSB_dragger{ height: 100px; } #mCSB_1_scrollbar_horizontal .mCSB_dragger{ width: 100px; } .mCSB_1_scrollbar .mCSB_dragger .mCSB_draggerRail{ width: 4px; }
User-defined callbacks
You can trigger your own js function(s) by calling them inside mCustomScrollbar callbacks option parameter
$(".content").mCustomScrollbar({ callbacks:{ onScroll:function(){ myCustomFn(this); } } }); function myCustomFn(el){ console.log(el.mcs.top); }
In the example above, each time a scroll event ends and content has stopped scrolling, the content’s top position will be logged in browser’s console. There are available callbacks for each step of the scrolling event:
onScrollStart
– triggers the moment a scroll event startswhileScrolling
– triggers while scroll event is runningonScroll
– triggers when a scroll event completesonTotalScroll
– triggers when content has scrolled all the way to bottom or rightonTotalScrollBack
– triggers when content has scrolled all the way back to top or left
You can set an offset value (pixels) for both onTotalScroll
and onTotalScrollBack
by setting onTotalScrollOffset
and onTotalScrollBackOffset
respectively (view example).
By default, onTotalScroll
and onTotalScrollBack
callbacks are triggered repeatedly. To prevent multiple calls when content is within their offset, set alwaysTriggerOffsets
option to false
(view example).
Additional callbacks:
onInit
onOverflowY
onOverflowX
onOverflowYNone
onOverflowXNone
onUpdate
onImageLoad
onSelectorChange
Returning values
The script returns a number of values and objects related to scrollbar that you can use in your own functions
this
– the original element containing the scrollbar(s)this.mcs.content
– the original content wrapper as jquery objectthis.mcs.top
– content’s top position (pixels)this.mcs.left
– content’s left position (pixels)this.mcs.draggerTop
– scrollbar dragger’s top position (pixels)this.mcs.draggerLeft
– scrollbar dragger’s left position (pixels)this.mcs.topPct
– content vertical scrolling percentagethis.mcs.leftPct
– content horizontal scrolling percentagethis.mcs.direction
– content’s scrolling direction (y or x)
Plugin-specific jQuery expressions
$("#myID:mcsInView")
- Select element(s) in your content that are within scrollable viewport.
As condition:$("#myID").is(":mcsInView");
$(".content:mcsOverflow")
- Select overflowed element(s) with visible scrollbar.
As condition:$(".content").is(":mcsOverflow");
$("#myID:mcsInSight")
$("#myID:mcsInSight(exact)")
- Select element(s) in your content that are in view of the scrollable viewport. Using the
exact
parameter will include elements that have any part of them (even 1 pixel) in view of the scrollable viewport.
As condition:$("#myID").is(":mcsInSight");
,$("#myID").is(":mcsInSight(exact)");
Plugin dependencies & requirements
- jQuery version 1.6.0 or higher
- Mouse-wheel support
License
This work is released under the MIT License.
You are free to use, study, improve and modify it wherever and however you like.
https://opensource.org/licenses/MIT
Donating helps greatly in developing and updating free software and running this blog 🙂
hi…
I’ve implemented your scripts into my test site on BC and it’s scrolling but i can’t work out why it’s not picking up the styling. It’s only picking up the standard scroll bar…
Can you point out what i need to change, if anything.
p.s. Great scrollers!!!
cheers
Shane Waugh
Hi there, I’m trying to implement this scrollbar, but it’s not working. I did everything – included all files, I calles the function and nothing.
Here is the link: http://ip-studio.sk/test
Please help!
Thank you.
You’ve set
media="print"
on the link to the jquery.mCustomScrollbar.css:<link href="/cms/content/themes/custom/Site/stylesheets/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" media="print" />
which means the CSS doesn’t load. Just remove it:
<link href="/cms/content/themes/custom/Site/stylesheets/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
or add “screen” as the value if you need the attribute.
Oh, thanks a lot 😉
Hello! Great scrollbar! I really enjoy it. But i have one question:
I want the scroller into one box in the web site (where the content is) but I want to be able scroll with the mouse from the all web site, not only from the box. Is it possible?
Thanks!
Not really. The mouse-wheel event binds on .mCustomScrollBox. That said, you could achieve what you need by manipulating .mCSB_container and .mCSB_scrollTools dimensions and/or position within the CSS. That of course depends heavily on the rest of your page layout.
I really appreciate your works!
I used that in a div centred in the middle of the page.
I ask you if there’s any way to continue the scrolling action after being arived at the bottom of the div (but, ofcourse, not at the end of the page -> the page still can be scrolled for some length).
Tanks a lot for any replies.
Stefano
I see what you mean. Currently there’s no way for such mouse-wheel behavior. I’ll need to work on that and see how I can implement it in the plugin. Thanks for the feedback.
Thanks a lot!
I”m having an issue fading divs on scroll.
In want to fade divs when I move this scrollbar. I’d like them to instantly fade out when there is a change on the scroller and then fade back in.
Also I’d like to stop this function from happening on the .stop event for the scroller
If I understand correctly, you cannot do that as there’s only one onScroll callback which runs when a single scroll is completed. For what you need, it would require an onScrollStart and an onScrollEnd callbacks which I’m not sure is possible to implement. Moreover it would greatly affect performance, especially when fading in and out content every few milliseconds.
Is there a way to set the scrollbar so that it’s always visible? Right now, I’m trying to use the scrollbar with some expanding content. The problem is that the collapsed content isn’t large enough to activate the scrollbar when the page first loads. And when the content does expand, it fails to activate the scrollbar after the fact. Thoughts?
You need to call the update method of the plugin after your content is expanded (and is long enough to need a scrollbar).
Example:
$(".content").mCustomScrollbar("update");
For more info and working examples please read “Plugin methods: update”. You may also find related info in “Configuration” and “Additional info” sections of the post.
hi,
how can i use this plugin with fancybox
i want to change scrollbar in fancybox
Thankyou 🙂
I cannot really provide specific instructions for using the plugin on markup generated by other scripts, plugins or applications. The implementation guide is the same for any element you want to add custom scrollbar. You probably need to find the overflow:auto div generated by fancybox and call mCustomScrollbar function on it.
hi
i got it.
Thank you so much for your reply.
Thank you 🙂
Hi, I’m using this in my site http://chipandironicus.com/ , but I’m having a few problems. It appears to work fine in Chrome, Safari, and Firefox, but I’m having problems with it in Internet Explorer 9 and Opera. In IE9, sometimes the scrollbar never appears and/or the content in the div overflows onto the rest of the site. This is seemingly random and I can’t get it to happen consistently, but it happens enough that it’s a problem. Sometimes it gets fixed if you refresh it a lot. The scroll bar seems to disappear more often if you are on a video page like this one: http://chipandironicus.com/videos/condemned/1.html and click the X button to go back to the index. Sometimes the content won’t overflow its div, but the scrollbar will still not appear. This also appears to be random.
The problem in Opera is a little different. If I am on a page with the scrollbar and click on a link that takes me to another page with a scrollbar, it’s fine. But if I then click the browser’s back button, the previous page will not have the scroll bar and the content will again overflow. The scrollbar is fine if you click on a link that takes you to the page, it only breaks when you click on the browser’s back button.
I’m not much of a coder so I can’t quite figure out what’s going on, but is there something wrong with the way I’m calling the scripts? For both Internet Explorer and Opera it seems like the problem is that the scripts aren’t being loaded.
Hi,
I cannot reproduce the issue regarding browser’s back button on Opera (version 12.02). I checked your pages with IE9 developer tools and I get “‘mCustomScrollbars’ is undefined” error (inside document ready, you’re calling mCustomScrollbars() which does not exist). Try removing it as it might break your pages. I also get more than one js errors when I click the close button of the video (probably video player errors).
That’s an amazing plugin!
Anyway, I need to get the width set by the plugin.
I’ve been using the plugin in a table which is responsive, so when it increase horizontally (resizing the browser), it “stop” increasing when the initial width set by the plugin is reached.
For instance, my initial screen is 1024 x 800 and my table is 1400px, the plugin set the width of his content in 1400px and applies properly scroll (all right so far). But when my screen increase horizontally (1800px for example) the table doesn’t seem to responde to it and stop when it reachs 1400px and a wasted space (400px) on the right appears.
I’m starting with Jquery and I find that if the plugin applies min-width instead width to the container, it would be perfect. Or if it’s not possible, then how can I get the width set by the plugin.
Sorry if my english is not good enough 🙂 But it’s not my native language.
Thanks!
Hi!
I’m currently using your plugin on a website. Everything works great except in chrome on windows. There I get a wierd scrolling effect (the content “bounces back”) and sometimes the content will get a “position:left” of several million putting the content way off the browser window.
See here for an example: http://marico-design.com/portfolio/category/design/
Any ideas?
Thanks for a great plugin!
Hi,
I can’t seem to reproduce the bouncing-back scrolling. I checked your page on Chrome version 21 (21.0.1180.89) on Windows 7 and scrolling (as well as the hover effects inside it) are very smooth.
Thanks for the quick reply.
I found out what was causing it… My stupid mistake.
Chrome was slightly zoomed in ( 110% zoom ). As soon as I changed that it worked great there too.
So everything’s coming together pretty well with this plugin. I’ve got it working with scrolling, scrollbuttons, and also added up/down cursors doing the same thing as the scroll buttons on this page:
Credits
Anyone wanting similar functionality, feel free to steal from my page 🙂
I’m now working on my blog page, where I want to have anchor links in my .sidebar div that will have the scroller scrollto each blog post but I must be not understanding how to do this properly. I’ve tried the js code in Simon Dau’s ,a href=”http://www.blog.kartogram.co.uk/post.cfm/custom-functionality-for-custom-scrollbar”>page but am having trouble.
You can see how I originally had it working using jquerytools here:
Old Blog
With this toolset I was able to just have my anchors in a typical html format (located in my .sidebar div) and the content would jump to the right place.
Where I’m at now:
Test Blog
The functionality I’m needing is:
1. scrollto anchors residing in the .sidebar with a naming convention of #itemnnn where nnn=numbers from 000-999 (allowing for lots of content obviously). Example would be #item123
2. scrollto next and prev buttons which could be located either in the .content window or the .sidebar (not sure which way I’ll go here). This method would be for jumping to the next item no matter what number it is on a page such as my News page.
Any help would be tremendously appreciated. I’m so close to having the infrastructure solid here this would mean I can finally launch my site soon!
Hi again Lennie,
Simon Dau’s code is an awesome extension for the previous version (1.0) of the plugin. On the current version (2), which is the one you’re using, I’ve implemented a pretty versatile scrollTo method that allows you to do what you describe.
You may need to read the “Plugin methods: ScrollTo” section on the post that explains how to use it to scroll-to any specific position within your content.
In short, you can do something like:
$("#yourLinkID").click(function(e){ e.preventDefault(); $(".content").mCustomScrollbar("scrollTo","#item123"); });
On the example above, when the #yourLinkID is clicked, the custom scrollbar will scroll-to the position of #item123 element inside your .content.
For the next/previous links, you should probably add a script that finds the next element to scroll-to (e.g. using jQuery $.next() function) and change ScrollTo target accordingly (same with previous).
Your links can be anywhere in your document (inside or outside the element with the custom scrollbar).
Cool, thx. I’ll get to work on this.
Progress. It’s scrolling to each blog post (thank you for the help!) but for some reason it’s not scrolling consistently to the h2 titles. They drift a bit in their location.
Check it out here.
Is it something in one of my scrollAmount settings? Or is it something else? Strange…
I used a half-baked workaround for now by inserting ” ” spacers at the end of each blog to get it close to what I need. Not an elegant hack.
It’d be good to know why the scrollto is not consistently going to the right location.
The slightly off scrolling to headings position, happens probably because of the way CSS handles element margins that overflow their container.
Try removing
<a id="item008"></a>
and add those ids on your divs. For example:
<div id="item008"> <div class="blogitem"> ... </div> </div>
or
<div> <div id="item008" class="blogitem"> ... </div> </div>
There are a few things you can also try like giving .blogitem and/or its parent divs overflow:hidden, “playing” with position:relative on the anchors and divs etc. but I think the above will fix any scroll-to position issues.
bummer. none of this seems to work. I did change the ids to the divs that makes more sense. Been tweaking the css and looking for the culprit but have found nothing so far.
btw thank you for the time in helping me on this. If you look on my blog on the “About This Website” post you’ll notice I’m going to be giving you a serious plug.
current blog page
Can’t thank you enough 🙂
Love the plugin!
Small issue
If you use ‘scrollTo’ hook and use an int of 0; than it won’t scroll.
in jquery.mCustomScrollbar.js
Line 600 needs to be changed
if(scrollTo){
to
if(typeof(scrollTo)!=’undefined’){
or
if(typeof(scrollTo)==’string’ || typeof(scrollTo)==’number’){
Yes, instead of 0, use “top” (or “left” for horizontal scrollbar).
Great plugin, sir. Excellent documentation. I am using it on my blog but maybe I will be able to use it for work one day if I get another web development project.
Hello,
I have container whose height is say 400 and overflow hidden. I also have a READ MORE button. When i click on read more i am enabling the plugin. Likewise i need to disable the plugin when i click READ LESS. Can it be achievable ?? Please help . Thanks in advance 🙂
You can increase or decrease your content height each time you click “read more” and “read less” accordingly. When your content is shorter than its container then the scrollbar is disabled (as no scrolling is needed). After plugin initiates, your original content resides within the .mCSB_container div (this div has by default overflow:hidden). Changing its height will do what you need.
Hi dude. I have a modal and a button on the site. if i click the button, the modal shows up. inside the modal, there’s the div i want the scrollbar to show up. However, pressing the button doubles the scrollbar. Any fix for this?
$("a[rel='show-content']").click(function(e){ e.preventDefault(); $("#content_1").fadeToggle("slow",function(){ var customScrollbar=$("#content_1").find(".mCSB_scrollTools"); customScrollbar.css({"opacity":0}); $("#content_1").mCustomScrollbar("update"); customScrollbar.animate({opacity:1},"slow"); }); });
I’ve been experimenting for 5 hours straight. 😀
$("#content_1").mCustomScrollbar();
that code gives the div the scrollbar, is there a reverse way for this? Thanks in advance sir!
Hello,
I’m guessing you’re calling
$("#content_1").mCustomScrollbar();
before your click event function, correct? When you say doubles the scrollbar, you mean you get 2 scrollbars?Can you send me a link to check the code? I can’t really be much help otherwise.
Very inspiring to me. It brings some Ideas to my mind.
Since I’m not a coder, just a Foto/Video Guy – may I ask possibly dumb questions?
like:
Performance- and functionional- wise, where to place the js-Scripts best in a WordPress-Theme? Globally? Like in the Header for the whole Page anytime?
Or better within in the Articles just where I want them?
and better than educate everybody:
🙂 Couldn’d you “just” make a WP-Plugin with Shortcode-support for dumb folks like mine? I wouldn’t mind paying/donating for such. You seem capable!
Hi Chris,
Depends on how often you’ll use the plugin in your WordPress and if you already have jQuery and jQuery UI loaded in your header or functions.php.
If you only plan on using it on some widget or specific page and you don’t need jQuery UI for other plugins, then you should probably include it only on the templates you want.
If you already using jQuery (and especially jQuery UI) for other plugins and/or plan to use the plugin often on any article, then you should include it in your header or functions.php.
jQuery is included by default in latest WordPress, so if you already use jQuery UI then the rest of the plugin files are something like 25kb, no big deal on loading times.
Another way would be to create 2 templates for your theme. One without the plugin and one with it. This way you could easily select the template you want for each of your posts, according to its content.
I’ll probably release a WordPress plugin at some point. I just need the new plugin version to be implemented and used as much as possible so I can get feedback and fix any errors or make additions before I release it for WordPress.
It doesn’t seem much work at first, but each time I change code, I need to update local files, remote files, github etc. Add WordPress repository and multiply by x number of plugins and it adds up very quickly! That’s why I try to go slowly and avoid releasing jQuery and WordPress plugins at the same time.
Thank you for your time answering me!
And thank you for the suggestions. I’ve put it in the functions.php. My longtime Goal is a compact Onepage Portfolio with a Slider Window per Article for Pictures/Video avoiding too deep Navigation and those Modal Windows (wich I find often too slow and irritating as a Userexperience)
I understand that it is a lot of work! Just wanted to let you know that it is much apreciated. And also thank’s for the good documentation. I personally may not be able to understand everything but that’s my learning curve now 🙂
And as I sayd: allthough I appreciate Free Software (and OpenSource Concepts in particular for Core Technologies) I shurely would spend some money on a convenience-raising Backend User Interface that enables me being creative without going into much coding (or finding and hiring a dedicated Programmer for it). For instance like shortcodes for the TinyMCE to embed the Customscrollbar with different options, choosable or custom uploadable graphics, automatic theme setup…
but maybe i’ll learn some more html/css/js – it looks interesting.
All the Best, Chris
Hi, is it possible to make a scrollTo with choosing coordinate like : scrollTo_x and scrollTo_y?
Actually, I was able to scroll verticaly with a integer value but not horizontaly…
Hi,
You cannot scroll to position horizontally and vertically at the same time, since the plugin does not support scrollbars for both axis on a single element.
Hi,
Great code. However I have noticed that the custom scrollbars do not show up on tablet PC or iPads.
Is their a correction for this?
Many thanks
Mediagrin
Hi,
I’ve intentionally avoided using custom scrollbars on touch devices cause I don’t want to mess with usability and the way users scrolling.
The plugin checks for touch devices and applies overflow: auto css rules, as well as -webkit-overflow-scrolling: touch to the content block so it can be scrolled natively by swiping.
Fair play and that makes sense.
Thanks for your replay.
I, thx for u’r script, he is very amazing.
But I want apply-it for scroollbar left! with the direction=”rtl” he won’t work it at left.
How I can do ?
Thx
You can set the scrollbar on the left of your content by changing the position of .mCustomScrollBox .mCSB_scrollTools within the jquery.mCustomScrollbar.css. You’d also need to set a left-margin for the .mCSB_container. For example:
.mCSB_container{ width:auto; margin-left:30px; overflow:hidden; } .mCSB_container.mCS_no_scrollbar{ margin-left:0; } .mCustomScrollBox .mCSB_scrollTools{ width:16px; height:100%; top:0; left:0; }
It’s working, thank’s for all. =)
Hello,
I’m using your script to scroll a list and when I switch stylesheet with :
$("link[rel=stylesheet]").attr("href",$(this).attr('rel'));
After used the switcher, the scroolbar disappears and the list scroll to the last item. Then I can’t use the mouse or drag’n’drop…
I try to use update method after switch, but it doesn’t work!
Thank in advance…
Best Regards
Julien
I can’t really know where the problem could be. Can you post a link so I can check it?
Hello,
You can download my project here : http://dl.free.fr/fCR6xcUgb
Open “index.htm” and click on “Theme 1” and “Theme 2” to switch CSS.
I use your script for the left side.
In the file :
– L.98 : code to switch css
– L.143 : transform to mCustomScrollbar
Thank you to have respond!
Julien
I made you a smaller projet :
http://dl.free.fr/qEZicY5GK
Cool plugin! Lots of potential for what I can use on my website.
I’m having a problem (mostly because I’m a composer and NOT a javascript programmer) getting the plugin to work. I can access the plugin fine and customize how it’s looking but my content disappears as soon as I use the scrollbar or mousewheel? Not sure what that’s about. I also can not access the arrow images from your png file.
Any help would be appreciated. My test web page for this is:
http://www.lenniemoore.com/credits_test.html
Thanks!
Hi,
It seems that you’ve hard-coded the custom scrollbar markup, which the plugin creates automatically. Your content markup should only have your own content. For example in your page it should be:
<article class="substance"> <section id="scrolltext"> <div class="content"> <div class="item"> ... </div> <div class="item"> ... </div> <div class="item"> ... </div> </div> </section> </article>
You don’t need to insert any of the divs that have to do with the scrollbar. The script does everything else.
Awesome. I knew it was something stupid on my end. I misunderstood the html examples above.
Thanks for saving a composers life.
Firstly thanks a lot for your donation. It greatly helps me focus on creating and supporting free software.
Off-topic:
When I checked the code on your page I was, as usual, seeing only the code… I didn’t notice you’re the composer of such awesome music until I took a more “relaxed” look and saw Outcast video game on the list!
Oh man! I loved your work on Outcast and I cannot even express myself on how much I absolutely love Watchmen motion comic OST. Seriously, I’m a big fan of your music.
Thanks for being a composer 🙂
LOL Thanks for the kind words and for making such a great plugin. I’m happy to donate to the cause.
I’m still trying to figure out why I don’t see any scroll button arrows from the .png file. I’ve put it in several directories on my server just in case the plug is looking in a particular location but I think the problem is somewhere in how I coded either the js or html. I probably have to turn something on eh?
$(window).load(function() { $(".content").mCustomScrollbar({ set_width:true, set_height:true, horizontalScroll:false, scrollInertia:660, scrollEasing:"easeOutQuart", mouseWheel:"auto", autoDraggerLength:true, scrollButtons:{ enable:true, scrollType:"pixels", scrollSpeed:80, scrollAmount:302 }, advanced:{ updateOnBrowserResize:true, updateOnContentResize:true, autoExpandHorizontalScroll:false }, callbacks:{ onScroll:function(){}, onTotalScroll:function(){}, onTotalScrollOffset:0 } }); });// $avaScript Document
Figured it out. I didn’t have the css correct.
You should also consider adding the following comments into the css file:
.mCSB_scrollTools .mCSB_buttonUp{ background-position:96px,0; /* buttonUp locations are 0 0/16px 0/32px 0/48px 0 (white) and 80px 0/96px 0/112px 0/128px 0 (black) */ } .mCSB_scrollTools .mCSB_buttonDown{ bottom: 0px; background-position:96px -20px; /* buttonDown locations are 0 -20px/16px -20px/32px -20px/48px -20px (white) and 80px -20px/96px -20px/112px -20px/128px -20px (black) */ } .mCSB_scrollTools .mCSB_buttonLeft{ background-position:100px -40px; /* buttonLeft locations are 0 -40px/20px -40px/40px -40px/60px -40px (white) and 80px -40px/100px -40px/120px -40px/140px -40px (black) */ } .mCSB_scrollTools .mCSB_buttonRight{ background-position:100px -56px; /* buttonRight locations are 0,-56px/20px -56px/40px -56px/60px -56px (white) and 80px -56px/100px -56px/120px -56px/140px -56px (black) */ }
Oops! Ignore that last note. I listed the wrong coordinates. I believe these will work better:
.mCSB_scrollTools .mCSB_buttonUp{ background-position:0 0; /* buttonUp locations are 0 0/-16px 0/-32px 0/-48px 0 (white) and -80px 0/-96px 0/-112px 0/-128px 0 (black) */ } .mCSB_scrollTools .mCSB_buttonDown{ bottom: 0px; background-position:0 -20px; /* buttonDown locations are 0 -20px/-16px -20px/-32px -20px/-48px -20px (white) and -80px -20px/-96px -20px/-112px -20px/-128px -20px (black) */ } .mCSB_scrollTools .mCSB_buttonLeft{ background-position:0 -40px; /* buttonLeft locations are 0 -40px/-20px -40px/-40px -40px/-60px -40px (white) and -80px -40px/-100px -40px/-120px -40px/-140px -40px (black) */ } .mCSB_scrollTools .mCSB_buttonRight{ background-position:0 -56px; /* buttonRight locations are 0,-56px/-20px -56px/-40px -56px/-60px -56px (white) and -80px -56px/-100px -56px/-120px -56px/-140px -56px (black) */
Good idea. I’ll put the dark and light buttons css locations in the stylesheet for reference. Thanks!
EDIT: Done.
Hi, this plug-in is very well put together and complete. I’m very impressed. I am trying to use it on a project where we have “tabbed content” using jQuery.
The code for the tabbed content looks like this:
$(".mission-content").hide(); $("ul.mission-menu li:first").addClass("active").show(); $(".mission-content:first").show(); $("ul.mission-menu li").click(function(e) { e.preventDefault(); $("ul.mission-menu li").removeClass("active"); $(this).addClass("active"); $(".mission-content").hide(); var activeTab = $(this).find("a").attr("href"); $(activeTab).fadeIn("slow",function(){ $(".mission-text").mCustomScrollbar("update"); }); });
The HTML markup looks like this:
<ul class="mission-menu"> <li><a href="#tab_1">Tab1 Menu Title</a></li> <li><a href="#tab_2">Tab2 Menu Title</a></li> </ul> <div id="main-content"> <div id=tab_1" class="mission-content"> <h2>Some title</h2> <div class="mission-text"> Lorem ipsum................ </div> </div> <div id=tab_2" class="mission-content"> <h2>Some title</h2> <div class="mission-text"> Lorem ipsum................ </div> </div> </div>
The tabs work fine and the scrollbar shows up fine on the first tab. But even with the “update” element in the tab jQuery ccode, it refuses to add in the scrollbars when the second tab is clicked.
What am I missing here?
E.
Hello,
I assume you have applied custom scrollbars to all your .mission-text elements like this:
$(".mission-text").mCustomScrollbar();
Is this correct?
Make sure .mission-text have a height value. Also, you can call the update method only on the active tab like this:
$(activeTab).fadeIn("slow",function(){ $(this).find(".mission-text").mCustomScrollbar("update"); });
An alternative way would be to apply a single custom scrollbar only on .main-content (which should have a height value specified and probably overflow:auto):
$(".main-content").mCustomScrollbar();
and update it:
$(activeTab).fadeIn("slow",function(){ $(".main-content").mCustomScrollbar("update"); });
This way, you use a single scrollbar instead of multiple ones for each tab.
Thank you Malihu. You are a star!
Yes, I did have the command to apply the scrollbars already in the code.
Just using your reformed jQuery code solved my problem. I knew I was missing something there.
Recommendations and a donation is on it’s way. I really appreciate you’re work here.
Cheers.
Hello. Im making one new website – http://radiorock-bg.com/test/darin/ . The design is not finished yet. I really liked your custom scrollbar and I want to use it but something is going wrong… I followed the steps here – http://manos.malihu.gr/jquery-custom-content-scroller but nothing happen. Please, can you help me a little bit…?
Hello,
In your CSS, you must give .content a height value (pixels, percentage etc.) instead of just max-height.
If you don’t want to define a specific height value and use only max-height, please see the following example and view its source to get the additional code:
http://manos.malihu.gr/tuts/custom-scrollbar-plugin/maxheight_example.html
Thanks man! It works 🙂
Sorry, can you remove or edit my post, `cuz I posted my contact data there…
Of course. Removed.
Hello, do your script support both vertical and horisontal scroll?
i’ve got page >8000x>13000px and do not want to use standart scrollbars…
Nope, only one axis scrolling on a single element.
Like this plugin and also detailed explaination.
Wish you best of luck.
Hey !
So I am trying to use this plugin, looks great, but I just can’t seem to get it working !
I have a simple div with overflow:auto; a height and a width, and I just can’t seem too scroll…
I was on jquery 1.8.0, but since the comment above said it wasn’t working with it I tried with 1.7.1 and still can’t get it working.
Do you think you could have a look ? Here’s the web page: http://pbmaintenance.fr/produits.php
It shows up but I just can’t scroll.
Thanks in advance !
Here use this
http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js
will not get any problem with this. I had made it with this
Hey !
Thanks for the link, but I tried it and still didn’t get this working :/
The scrollbar works on latest Firefox and Chrome. I get a js error on IE9 which probably break the page.
Not working with jQuery 1.8 even though i receive no console errror at all ._.
… it took me 2h to realise it was the jQuery’s fault :[
Hi,
It does work with jQuery 1.8. Try to use jQuery 1.8 with the latest version of jQuery UI (1.8.22 or 1.8.23).
EDIT: I’ve included jquery-1.8.0.min.js and jquery-ui-1.8.23.custom.min.js in the download archive.
Lovely work! Thank you Sir.
I’ve implemented your slider. It’s slotting in really easily, but I’m having an issue in Chrome, the images judder when sliding. FF & IE9 are working well.
You can see the page here http://wgmphoto.com/21c. If you click on the red 21C I slide out a pane which has the slider.
The images are a bit big and will be reduced in the final version, but I don’t believe that should cause what I’m seeing.
Can you see the issue / a solution?
Thanks again, W.
Hello,
Images judder is due to browser’s engine performance.
You could reduce the images and maybe remove box-shadow (CSS shadows have big impact on performance esp. in Chrome).
You could also try setting scrollInertia option parameter to zero, which removes the scrolling easing:
scrollInertia:0
Fucking great man!
Thanks for great script!
I found an issue.
It appears in last Firefox and Opera, not Chrome.
If I use @font-face (Century Gothic in .ttf format actually, I think others too) in scroll area and move scrollbar to the bottom position (or scroll with mouse wheel to the end) there is still some text that not displayed because it below visible area.
But I found some kind of workaround. This would be simplier with ‘onInit’ or ‘onLoad’ callback.
updated = false; $(".scroll").mCustomScrollbar({ callbacks:{ onScroll:function(){ if (!updated) { // run this only once $(".scroll").mCustomScrollbar("update"); // after this all text becomes visible when scrollbar at bottom position updated = true; } } } });
Hello,
On the demos I use custom fonts without any issues so I can’t really say what could be wrong. Sounds like fonts are not fully loaded when plugin initiates. Do you call mCustomScrollbar on window load or document ready? To make sure fonts are loaded, you must call the plugin on window load.