📜 ⬆️ ⬇️

Making a scrollbar (cross-browser)

I did not find a similar article on Habré, and then I just had to face this problem.

Consider two solutions to this problem, on different frameworks - jQuery ( jScrollPane ) and MooTools ( MooTools ScrollContro ).


')
So, frameworks.

MooTools ScrollContro

The plugin allows you to replace the scrollbar in any container in which it is used (the number of containers is not limited).
Available features:



Besides:



pros:



It is very easy to use. Just place the content in a container with the identifier #contentcontainer:

Text content



At the same time, its design may be different, but in the CSS description there must be an overflow: auto or overflow: scroll attribute. For example:

#contentcontainer {
height: 300px;
width: 435px;
padding-top: 0;
padding-right: 10px;
overflow: scroll;
overflow-x: hidden;
margin-top: 20px;
font-size: 1.1em;
}


You need to enable the work of the plugin itself using a simple function:

window.addEvent('domready', function() {
new ScrollControl($('contentcontainer'), {'createControls': true});
});


When using multiple containers, they need to be assigned different identifiers. You can define the names for the controls and for the scrolling container, if you want the second container to be different from the first:

new ScrollControl($('contentcontainer1'), {'htmlElementPrefix': 'control2_'}, $('scrolltrack1'), $('scrollknob1'), $('scrollUpBtn1'), $('scrollDownBtn1'));

Where:



To use, you will need the Mootools 1.11 library and the plugin itself, which can be downloaded from eSteak.net . Plugin created by A + media.

jScrollPane

jScrollPane - jQuery plugin that allows you to replace the default browser scrolling bar in any block with overflow: auto style.
You can change the appearance of scrolling using CSS.

jScrollPane cross-browser jQuery solution. If the user's browser does not support jQuery or JavaScript, then it will see the default system scroll. For an exact copy of all mouse events, you need to connect an additional mouse wheel plugin.

Using
Connect the following files.



All files can be downloaded from the jScrollPane page.

You can use any selector with respect to the element to which you want to apply the action of the plugin. For example, with the code below, the plugin works when the document contains at least one element with the class scroll-pane:

$(function()
{
$('.scroll-pane').jScrollPane();
});


Extra options:

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


All Articles