Problem with replacing default scrollbar with jQuery plugin

I would like to replace the default scrollbar on my site ( THIS page in particular) using a jQuery plugin called TinyScrollbar . However, for some reason, I get the following error on the page:

jquery.tinyscrollbar.min.js:1Uncaught TypeError: Cannot read property 'offsetHeight' of undefined 

You can see this error by checking an item in Chrome.

Anyone have any ideas why this error is occurring? The code that I use to initialize the plugin can be seen below:

 $('#full-height-template-container').tinyscrollbar(); 
+6
source share
2 answers

The problem is that you are not using the plugin since you have to use it.

The error (in firefox firebug), using the tinescrollbar source file, shows: oViewport.obj[0] is undefined . If you look at a few lines in the source code, you will see that the obj oViewport property is defined as: $('.viewport', root) . Here root is your container. Apparently, it does not find the html element with the .viewport class. Your page does not contain an html element with such a class!

If you look at the tinyscrollbar website , you can see in the How to section how to create the correct HTML code for the plugin to work.

Perhaps a simpler (similar plugin) you can use is jScrollPane . Does not require HTML to be configured as a tiniscrollbar.

+19
source

The Tiny Scrollbar website does not mention that the JS library has class names hardcoded in it. You can change this by expanding the library to accept class names for the individual, required html elements.

0
source

Source: https://habr.com/ru/post/913350/


All Articles