Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Support for Horizontal Scrollbars #230

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
node_modules
66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,67 @@

slimScroll is a small jQuery plugin that transforms any div into a scrollable area with a nice scrollbar - similar to the one Facebook and Google started using in their products recently. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over. User can drag the scrollbar or use mouse-wheel to change the scroll value.

Demo and deocumentation available here: [jQuery slimScroll docs](http://rocha.la/jQuery-slimScroll)
Demo and deocumentation available here: [jQuery slimScroll docs](http://lanre-ade.github.io/jQuery-slimScroll/)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should probably not have been changed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added new examples for horizontal scrolling. Any suggestions where to put them? @deiga

Copy link

@deiga deiga Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add them directly into the Readme?


Copyright (c) 2011 Piotr Rochala (http://rocha.la)
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
#This Fork Supports both Horizontal and Vertical Scrollbars.
### The initialization options have been modified to accomodate horizontal scroll bars. See below for details.

*axis* - x(X) or y(Y) or both - Axis to apply scrollbars. Default: y.
Note: the plugin detects if the content size exceeds the div dimensions and creates scrollbars accordingly. If width and height are specified in the options, they'll be used in place of the div dimensions.

*width* - Width in pixels of the visible scroll area. Stretch-to-parent if not set. Default: auto

*height* - Height in pixels of the visible scroll area. Also supports auto to set the height to same as parent container. Default: 250px

*size* - Width in pixels of the scrollbar. Default: 7px

*positionX* - top or bottom. Sets the position of the horizontal scrollbar. Default: bottom

*positionY* - left or right. Sets the position of the vertical scrollbar. Default: right

*color* - Color in hex of the scrollbar. Default: #000000

*alwaysVisible* - Disables scrollbar hide. Default: false

*distance* - Distance in pixels from the edge of the parent element where scrollbar should appear. It is used together with position property. Default:1px

*startX* - left or right or $(selector) - defines initial position of the horizontal scrollbar. When set to left it automatically scrolls to the left of the scrollable container. When HTML element is passed, slimScroll defaults to offsetLeft of this element. Default: left.

*startY* - top or bottom or $(selector) - defines initial position of the vertical scrollbar. When set to bottom it automatically scrolls to the bottom of the scrollable container. When HTML element is passed, slimScroll defaults to offsetTop of this element. Default: top.

*wheelStep* - Integer value for mouse wheel delta. Default: 20

*railVisible* - Enables scrollbar rail. Default: false

*railColor* - Sets scrollbar rail color, Default: #333333

*railOpacity* - Sets scrollbar rail opacity. Default: 0.2

*allowPageScroll* - Checks if mouse wheel should scroll page when bar reaches extremities of the container. When set to true is scrolls the page. Default: false

*scrollToX* - Jumps to the specified horizontal scroll value. Can be called on any element with slimScroll already enabled.
Example: `$(element).slimScroll({ scrollToX: '50px' });`

*scrollByX* - Increases/decreases current horizontal scroll value by specified amount (positive or negative). Can be called on any element with slimScroll already enabled.
Example: `$(element).slimScroll({ scrollByX: '60px' });`

*scrollToY* - Jumps to the specified vertical scroll value. Can be called on any element with slimScroll already enabled.
Example: `$(element).slimScroll({ scrollToY: '50px' });`

*scrollByY* - Increases/decreases current vertical scroll value by specified amount (positive or negative). Can be called on any element with slimScroll already enabled.
Example: `$(element).slimScroll({ scrollByY: '60px' });`

*disableFadeOut* - Disables scrollbar auto fade. When set to true scrollbar doesn't disappear after some time when mouse is over the slimscroll div.Default: false

*touchScrollStep* - Allows to set different sensitivity for touch scroll events. Negative number inverts scroll direction. Default: 200


######Events
slimScroll publishes slimscrollX, slimscrollY, slimscrollingX and slimscrollingY events when the corresponding scrollbar moves along the parent container. You can use jQuery bind method to subscribe to these events

$(selector).slimScroll().bind('slimscrollX', function(e, pos){
console.log("Horizontal Scrollbar Reached " + pos + "px");
});

Copyright (c) 2011 Piotr Rochala (http://rocha.la), Lanre Adebambo
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
2 changes: 1 addition & 1 deletion examples/allow-page-scroll.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@
})();
</script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion examples/chaining.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@
})();
</script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion examples/disable-fade-out.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@
})();
</script>
</body>
</html>
</html>
42 changes: 41 additions & 1 deletion examples/dynamic-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,28 @@
});
</pre>

<div id="testDiv2">
<p></p>
</div>

<pre class="prettyprint">
// update content every second
setInterval(function(){

$('#testDiv2').find('p').append(' ' + new Date() + ' ');

// update slimscroll every time content changes
$('#testDiv2').slimscroll();

}, 1000);

$('#testDiv2').slimscroll({
alwaysVisible: true,
height: '50px',
axis: 'x'
});

</pre>
</div>

<script type="text/javascript">
Expand All @@ -58,6 +78,26 @@
});

});

$(function(){

// update content every second
setInterval(function(){

$('#testDiv2').find('p').append(new Date().getTime() + '||');

// update slimscroll every time content changes
$('#testDiv2').slimscroll();

}, 1000);

$('#testDiv2').slimscroll({
alwaysVisible: true,
height: '50px',
axis: 'x'
});

});
</script>


Expand All @@ -78,4 +118,4 @@
})();
</script>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions examples/height-width.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<body>
<a id="git-fork" href="https://github.com/rochal/jQuery-slimScroll"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<div class="examples">
<div style="height:300px;">
<div style="height:300px;width:700px;">
<div id="testDiv">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus, felis interdum condimentum consectetur, nisl libero elementum eros, vehicula congue lacus eros non diam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus mauris lorem, lacinia id tempus non, imperdiet et leo. Cras sit amet erat sit amet lacus egestas placerat. Aenean ultricies ultrices mauris ac congue. In vel tortor vel velit tristique tempus ac id nisi. Proin quis lorem velit. Nunc dui dui, blandit a ullamcorper vitae, congue fringilla lectus. Aliquam ultricies malesuada feugiat. Vestibulum placerat turpis et eros lobortis vel semper sapien pulvinar.</p>
<p>Pellentesque rhoncus aliquet porta. Sed vel magna eu turpis pharetra consequat ut vitae lectus. In molestie sollicitudin mi sit amet convallis. Aliquam erat volutpat. Nullam feugiat placerat ipsum eget malesuada. Nulla facilisis nunc non dolor vehicula pretium. Sed dui magna, sodales id pharetra non, ullamcorper eu sapien. Mauris ac consectetur leo. Mauris consequat, lectus ut bibendum pulvinar, leo magna feugiat enim, eu commodo lacus sem vel ante. Sed tempus metus eget leo mollis vulputate. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
Expand Down Expand Up @@ -122,4 +122,4 @@
})();
</script>
</body>
</html>
</html>
10 changes: 5 additions & 5 deletions examples/mouse-wheel.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<pre class="prettyprint">
$('#testDiv').slimScroll({
wheelStep: 20
wheelStep: 2
});
</pre>

Expand All @@ -58,7 +58,7 @@

<pre class="prettyprint">
$('#testDiv2').slimScroll({
wheelStep: 100
wheelStep: 10
});
</pre>

Expand All @@ -68,11 +68,11 @@
$(function(){

$('#testDiv').slimScroll({
wheelStep: 20
wheelStep: 2
});

$('#testDiv2').slimScroll({
wheelStep: 100
wheelStep: 10
});

});
Expand All @@ -96,4 +96,4 @@
})();
</script>
</body>
</html>
</html>
3 changes: 2 additions & 1 deletion examples/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ <h2>Facebook-style jQuery Scrollbar</h1>
<li><a target="main" href="mouse-wheel.html">wheelStep option</a></li>
<li><a target="main" href="nested.html">nested elements</a></li>
<li><a target="main" href="dynamic-content.html">dynamic content</a></li>
<li><a target="main" href="vertical-horizontal.html">Restrict Axes</a></li>
</ul>
</div>
</body>
</html>
</html>
18 changes: 9 additions & 9 deletions examples/programmatic-scrolling.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
});

$('#scrollDown').click(function(){
$('#testDiv').slimScroll({ scrollBy: '50px' });
$('#testDiv').slimScroll({ scrollByY: '50px' });
});

$('#scrollUp').click(function(){
$('#testDiv').slimScroll({ scrollBy: '-50px' });
$('#testDiv').slimScroll({ scrollByY: '-50px' });
});
</pre>

Expand Down Expand Up @@ -76,11 +76,11 @@
});

$('#scrollDownTo').click(function(){
$('#testDiv2').slimScroll({ scrollTo: '300px' });
$('#testDiv2').slimScroll({ scrollToY: '300px' });
});

$('#scrollUpTo').click(function(){
$('#testDiv2').slimScroll({ scrollTo: '20px' });
$('#testDiv2').slimScroll({ scrollToY: '20px' });
});
</pre>

Expand All @@ -95,23 +95,23 @@
});

$('#scrollDown').click(function(){
$('#testDiv').slimScroll({ scrollBy: '50px' });
$('#testDiv').slimScroll({ scrollByY: '50px' });
});

$('#scrollUp').click(function(){
$('#testDiv').slimScroll({ scrollBy: '-50px' });
$('#testDiv').slimScroll({ scrollByY: '-50px' });
});

$('#testDiv2').slimscroll({
height: '250px'
});

$('#scrollDownTo').click(function(){
$('#testDiv2').slimScroll({ scrollTo: '300px' });
$('#testDiv2').slimScroll({ scrollToY: '300px' });
});

$('#scrollUpTo').click(function(){
$('#testDiv2').slimScroll({ scrollTo: '20px' });
$('#testDiv2').slimScroll({ scrollToY: '20px' });
});

});
Expand All @@ -135,4 +135,4 @@
})();
</script>
</body>
</html>
</html>
Loading