diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9daa824 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +node_modules diff --git a/README.md b/README.md index bc90347..d2104f7 100644 --- a/README.md +++ b/README.md @@ -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/) -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. \ No newline at end of file +#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. diff --git a/examples/allow-page-scroll.html b/examples/allow-page-scroll.html index b594de3..2e79f87 100644 --- a/examples/allow-page-scroll.html +++ b/examples/allow-page-scroll.html @@ -91,4 +91,4 @@ })(); - \ No newline at end of file + diff --git a/examples/chaining.html b/examples/chaining.html index fead426..62d85d5 100644 --- a/examples/chaining.html +++ b/examples/chaining.html @@ -77,4 +77,4 @@ })(); - \ No newline at end of file + diff --git a/examples/disable-fade-out.html b/examples/disable-fade-out.html index 7c8e6fa..7ecda44 100644 --- a/examples/disable-fade-out.html +++ b/examples/disable-fade-out.html @@ -91,4 +91,4 @@ })(); - \ No newline at end of file + diff --git a/examples/dynamic-content.html b/examples/dynamic-content.html index 1ac5e56..e486187 100644 --- a/examples/dynamic-content.html +++ b/examples/dynamic-content.html @@ -35,8 +35,28 @@ }); +
+

+
+ +
+  // 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'
+  });
+
+  
@@ -78,4 +118,4 @@ })(); - \ No newline at end of file + diff --git a/examples/height-width.html b/examples/height-width.html index 4b006b0..8cd205d 100644 --- a/examples/height-width.html +++ b/examples/height-width.html @@ -13,7 +13,7 @@ Fork me on GitHub
-
+

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.

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.

@@ -122,4 +122,4 @@ })(); - \ No newline at end of file + diff --git a/examples/mouse-wheel.html b/examples/mouse-wheel.html index 434c80c..35d2c95 100644 --- a/examples/mouse-wheel.html +++ b/examples/mouse-wheel.html @@ -34,7 +34,7 @@
   $('#testDiv').slimScroll({
-      wheelStep: 20
+      wheelStep: 2
   });
 
@@ -58,7 +58,7 @@
   $('#testDiv2').slimScroll({
-      wheelStep: 100
+      wheelStep: 10
   });
 
@@ -68,11 +68,11 @@ $(function(){ $('#testDiv').slimScroll({ - wheelStep: 20 + wheelStep: 2 }); $('#testDiv2').slimScroll({ - wheelStep: 100 + wheelStep: 10 }); }); @@ -96,4 +96,4 @@ })(); - \ No newline at end of file + diff --git a/examples/navigation.html b/examples/navigation.html index 2df6272..ce2d09f 100644 --- a/examples/navigation.html +++ b/examples/navigation.html @@ -24,7 +24,8 @@

Facebook-style jQuery Scrollbar

  • wheelStep option
  • nested elements
  • dynamic content
  • +
  • Restrict Axes
  • - \ No newline at end of file + diff --git a/examples/programmatic-scrolling.html b/examples/programmatic-scrolling.html index 163e753..dd9bcd0 100644 --- a/examples/programmatic-scrolling.html +++ b/examples/programmatic-scrolling.html @@ -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' }); }); @@ -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' }); }); @@ -95,11 +95,11 @@ }); $('#scrollDown').click(function(){ - $('#testDiv').slimScroll({ scrollBy: '50px' }); + $('#testDiv').slimScroll({ scrollByY: '50px' }); }); $('#scrollUp').click(function(){ - $('#testDiv').slimScroll({ scrollBy: '-50px' }); + $('#testDiv').slimScroll({ scrollByY: '-50px' }); }); $('#testDiv2').slimscroll({ @@ -107,11 +107,11 @@ }); $('#scrollDownTo').click(function(){ - $('#testDiv2').slimScroll({ scrollTo: '300px' }); + $('#testDiv2').slimScroll({ scrollToY: '300px' }); }); $('#scrollUpTo').click(function(){ - $('#testDiv2').slimScroll({ scrollTo: '20px' }); + $('#testDiv2').slimScroll({ scrollToY: '20px' }); }); }); @@ -135,4 +135,4 @@ })(); - \ No newline at end of file + diff --git a/examples/rail.html b/examples/rail.html index 4f77f34..155d126 100644 --- a/examples/rail.html +++ b/examples/rail.html @@ -138,6 +138,31 @@ }); +
    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +
    + +
    +$('#testDiv6').slimscroll({
    +  axis: 'x',
    +  width: '750px',
    +  railVisible: true,
    +});
    +
    @@ -187,4 +218,4 @@ })(); - \ No newline at end of file + diff --git a/examples/scroll-events.html b/examples/scroll-events.html index 9eabbdc..96bbc26 100644 --- a/examples/scroll-events.html +++ b/examples/scroll-events.html @@ -14,7 +14,7 @@ Fork me on GitHub
    -
    +

    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.

    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.

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    @@ -27,7 +27,7 @@
       $('#testDiv').slimscroll({
         alwaysVisible: true
    -  }).bind('slimscroll', function(e, pos) {
    +  }).bind('slimscrollY', function(e, pos) {
         $('#testDivOut').append("Reached " + pos + ", ");
       });
     
    @@ -43,7 +43,7 @@
    -  $('#testDiv2').slimscroll().bind('slimscrolling', function(e, pos) {
    +  $('#testDiv2').slimscroll().bind('slimscrollingY', function(e, pos) {
         $('#testDivOut2').append("Scroll value: " + pos + "px");
       });
     
    @@ -56,11 +56,11 @@ $('#testDiv').slimscroll({ alwaysVisible: true - }).bind('slimscroll', function(e, pos) { + }).bind('slimscrollY', function(e, pos) { $('#testDivOut').append("Reached " + pos + ", "); }); - $('#testDiv2').slimscroll().bind('slimscrolling', function(e, pos) { + $('#testDiv2').slimscroll().bind('slimscrollingY', function(e, pos) { $('#testDivOut2').append("Scroll: " + pos + "px, "); }); @@ -85,4 +85,4 @@ })(); - \ No newline at end of file + diff --git a/examples/scrollbar.html b/examples/scrollbar.html index 9f13b03..8e544c2 100644 --- a/examples/scrollbar.html +++ b/examples/scrollbar.html @@ -3,8 +3,8 @@ jquery.slimscroll - scrollbar options - - + + @@ -35,6 +35,7 @@
       $('#testDiv').slimscroll({
         size: '15px'
    +    height : '250px',
       });
     
    @@ -58,7 +59,8 @@
       $('#testDiv2').slimScroll({
    -      position: 'left'
    +      positionY: 'left',
    +      height : '250px',
       });
     
    @@ -82,7 +84,8 @@
       $('#testDiv3').slimScroll({
    -      color: '#00f'
    +      color: '#00f',
    +      height : '250px',
       });
     
    @@ -108,7 +111,8 @@
       $('#testDiv4').slimScroll({
    -      alwaysVisible: true
    +      alwaysVisible: true,
    +      height : '250px',
       });
     
    @@ -135,7 +139,8 @@
       $('#testDiv5').slimScroll({
           distance: '20px',
    -      opacity: 1
    +      opacity: 1,
    +      height : '250px',
       });
     
    @@ -145,24 +150,31 @@ - \ No newline at end of file + diff --git a/examples/start-position.html b/examples/start-position.html index 8afdda6..27c6f27 100644 --- a/examples/start-position.html +++ b/examples/start-position.html @@ -34,7 +34,7 @@
       $('#testDiv').slimScroll({
    -      start: 'bottom'
    +      startY: 'bottom'
       });
     
    @@ -58,7 +58,7 @@
       $('#testDiv2').slimScroll({
    -      start: $('.helloDiv')
    +      startY: $('.helloDiv')
       });
     
    @@ -69,11 +69,11 @@ $(function(){ $('#testDiv').slimScroll({ - start: 'bottom' + startY: 'bottom' }); $('#testDiv2').slimScroll({ - start: $('.helloDiv') + startY: $('.helloDiv') }); }); @@ -97,4 +97,4 @@ })(); - \ No newline at end of file + diff --git a/examples/vertical-horizontal.html b/examples/vertical-horizontal.html new file mode 100644 index 0000000..ce38eb4 --- /dev/null +++ b/examples/vertical-horizontal.html @@ -0,0 +1,121 @@ + + + +jquery.slimscroll - vertical / horizontal + + + + + + + + + + + +Fork me on GitHub +
    +
    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +
    + +
    +$('#testDiv').slimscroll({
    +height: '150px',
    +width: '300px',
    +axis: 'both'
    +});
    +
    + +
    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +
    + +
    +$('#testDiv2').slimscroll({
    +height: '150px',
    +width: '300px',
    +axis: 'y'
    +});
    +
    + +
    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +

    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.

    +

    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.

    +

    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed pulvinar rhoncus quam, vel semper tellus viverra id. Nulla rutrum porttitor odio, a rutrum purus gravida non. Etiam ac purus augue, eget vestibulum purus. Aenean venenatis ullamcorper augue, non consequat elit tempor sed. Donec velit sapien, volutpat sed ultricies egestas, semper a ante. Fusce dapibus, quam eget auctor suscipit, nibh leo posuere ante, at auctor nisi lacus in sem. Morbi interdum consectetur euismod. Cras accumsan est lacus. Nulla eleifend, eros vel consequat commodo, arcu nunc malesuada nunc, quis sagittis felis sem ac turpis.

    +

    Nulla rhoncus elementum convallis. Mauris condimentum aliquet egestas. Ut iaculis nisi eget tellus accumsan venenatis. Maecenas imperdiet aliquam porta. Aenean ultrices dolor sed quam laoreet varius. Curabitur condimentum blandit erat, quis accumsan eros interdum vitae. Curabitur ligula arcu, sollicitudin vitae iaculis sed, blandit sit amet enim. Morbi ullamcorper, metus vel mollis tristique, arcu turpis malesuada nisi, at dignissim lorem odio a orci. Proin ultrices, ipsum ut vestibulum interdum, libero felis auctor mi, vitae convallis nisl justo ac tellus. Integer nec lacinia turpis. Etiam massa nisl, rhoncus quis rutrum in, pretium eu leo. Proin a velit ut nulla laoreet vestibulum. Curabitur eu elit vitae felis auctor tincidunt. Curabitur tincidunt, metus sed sollicitudin cursus, quam elit commodo erat, ut tempor erat sapien vitae velit. Morbi nec viverra erat.

    +

    Nullam scelerisque facilisis pretium. Vivamus lectus leo, commodo ac sagittis ac, dictum a mi. Donec quis massa ut libero malesuada commodo in et risus. Fusce nunc dolor, aliquet vel rutrum in, molestie sit amet massa. Aliquam suscipit, justo a commodo condimentum, enim sapien fringilla ante, sed lobortis orci lectus in ante. Donec vel interdum est. Donec placerat cursus lacus, eu ultricies nisl tincidunt a. Fusce libero risus, sagittis eleifend iaculis aliquet, condimentum vitae diam. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin leo purus, sodales a venenatis luctus, faucibus ac enim. Sed id metus ac sem lobortis pretium. Mauris faucibus tempor scelerisque. Nunc vulputate interdum tortor, non tincidunt dui condimentum eget. Aenean in porttitor velit. Nam accumsan rhoncus risus id consectetur.

    +
    + +
    +$('#testDiv2').slimscroll({
    +height: '150px',
    +width: '300px',
    +axis: 'x'
    +});
    +
    + +
    + + diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..adb89cf --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,43 @@ +/* File: gulpfile.js */ + +// grab our gulp packages +var gulp = require('gulp'), +watch = require('gulp-watch'), +gutil = require('gulp-util'), +jshint = require('gulp-jshint'), +rename = require('gulp-rename'), +uglify = require('gulp-uglify'); + +var handleError = function (error) { + // details of the error in the console + gutil.log(error.toString()); + this.emit('end'); +} + +// configure the jshint task +gulp.task('sanitize', function() { + return gulp.src('jquery.slimscroll.js') + .pipe(jshint()) + .pipe(jshint.reporter('jshint-stylish')); +}); + +gulp.task('compress',['sanitize'], function() { + return gulp.src('jquery.slimscroll.js') + // .pipe(jshint()) + // .pipe(jshint.reporter('jshint-stylish')) + .pipe(uglify().on('error', handleError)) + .pipe(rename({ + extname: ".min.js" + })) + .pipe(gulp.dest('./')); +}); + +// configure which files to watch and what tasks to use on file changes +gulp.task('watch', ['compress'], function() { + watch('jquery.slimscroll.js', function() { + gulp.start('compress'); + }); +}); + +// define the default task and add the watch task to it +gulp.task('default', ['watch']); diff --git a/jquery.slimscroll.js b/jquery.slimscroll.js index 2b26ca0..d7f8e42 100644 --- a/jquery.slimscroll.js +++ b/jquery.slimscroll.js @@ -1,4 +1,4 @@ -/*! Copyright (c) 2011 Piotr Rochala (http://rocha.la) +/*! 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. * @@ -12,6 +12,9 @@ var defaults = { + // axis to apply scrollbars x(X) / y(Y) / both + axis: 'y', + // width in pixels of the visible scroll area width : 'auto', @@ -24,17 +27,23 @@ // scrollbar color, accepts any hex/color value color: '#000', + // scrollbar position - top/bottom + positionX : 'bottom', + // scrollbar position - left/right - position : 'right', + positionY : 'right', // distance in pixels between the side edge and the scrollbar distance : '1px', + // default scroll position on load - left/right / $('selector') + startX : 'left', + // default scroll position on load - top / bottom / $('selector') - start : 'top', + startY : 'top', // sets scrollbar opacity - opacity : .4, + opacity : 0.4, // enables always-on mode for the scrollbar alwaysVisible : false, @@ -49,16 +58,22 @@ railColor : '#333', // sets rail opacity - railOpacity : .2, + railOpacity : 0.2, // whether we should use jQuery UI Draggable to enable bar dragging railDraggable : true, - // defautlt CSS class of the slimscroll rail - railClass : 'slimScrollRail', + // defautlt CSS class of the slimscroll rail in X axis + railClassX : 'slimScrollRailX', + + // defautlt CSS class of the slimscroll bar in X Axis + barClassX : 'slimScrollBarX', + + // defautlt CSS class of the slimscroll rail in Y axis + railClassY : 'slimScrollRailY', - // defautlt CSS class of the slimscroll bar - barClass : 'slimScrollBar', + // defautlt CSS class of the slimscroll bar in Y axis + barClassY : 'slimScrollBarY', // defautlt CSS class of the slimscroll wrapper wrapperClass : 'slimScrollDiv', @@ -66,6 +81,9 @@ // check if mousewheel should scroll the window if we reach top/bottom allowPageScroll : false, + // check if force vertical movement of mousewheel to scroll a area whose axis is 'x' + applyVerticalWheelToHorizontal : false, + // scroll amount applied to each mouse wheel step wheelStep : 20, @@ -81,68 +99,123 @@ var o = $.extend(defaults, options); + // normalize to lower case for ease of handling + o.axis = o.axis.toLowerCase(); + // do it for every element that matches selector this.each(function(){ - - var isOverPanel, isOverBar, isDragg, queueHide, touchDif, - barHeight, percentScroll, lastScroll, + var hasHorizontalScrollbar; + var hasVerticalScrollbar; + var t, pageX, pageY; + var isOverPanel, isOverBarX, isOverBarY, isDragg, queueHideX, queueHideY, touchDifX, touchDifY, + barHeight, barWidth, percentScrollX, lastScrollX, percentScrollY, lastScrollY, divS = '
    ', minBarHeight = 30, + minBarWidth = 30, releaseScroll = false; // used in event handlers and for better minification var me = $(this); + var $doc = $(document); // ensure we are not binding it again if (me.parent().hasClass(o.wrapperClass)) { + $.extend(o, (me.data('slimScrollConfig') || {})); //retrieve previous config // start from last bar position - var offset = me.scrollTop(); + var offset_horizontal = me.scrollLeft(); + var offset_vertical = me.scrollTop(); // find bar and rail - bar = me.siblings('.' + o.barClass); - rail = me.siblings('.' + o.railClass); + barX = me.siblings('.' + o.barClassX); + railX = me.siblings('.' + o.railClassX); + barY = me.siblings('.' + o.barClassY); + railY = me.siblings('.' + o.railClassY); - getBarHeight(); + //check that scroll bars are enabled + hasHorizontalScrollbar = (o.axis == 'both' || o.axis == 'x'); + hasVerticalScrollbar = (o.axis == 'both' || o.axis == 'y'); + + getBarXWidth(); + getBarYHeight(); // check if we should scroll existing instance if ($.isPlainObject(options)) { + + // Pass width: auto to an existing slimscroll object to force a resize after contents have changed + if ( 'width' in options && hasHorizontalScrollbar) { + if (options.width == 'auto') { + me.parent().css('width', 'auto'); + me.css('width', 'auto'); + o.width = me.parent().parent().width(); + } + else { + o.width = options.width; + me.css({'white-space': 'nowrap'}); + } + } + // Pass height: auto to an existing slimscroll object to force a resize after contents have changed - if ( 'height' in options && options.height == 'auto' ) { - me.parent().css('height', 'auto'); - me.css('height', 'auto'); - var height = me.parent().parent().height(); - me.parent().css('height', height); - me.css('height', height); - } else if ('height' in options) { - var h = options.height; - me.parent().css('height', h); - me.css('height', h); + if ( 'height' in options && hasVerticalScrollbar) { + if(options.height == 'auto'){ + me.parent().css('height', 'auto'); + me.css('height', 'auto'); + o.height = me.parent().parent().height(); + } else { + o.height = options.height; + } } - if ('scrollTo' in options) + // rewrap content + me.parent().css({ + position: 'relative', + overflow: 'hidden', + width: o.width, + height: o.height + }); + + // update style for the div + me.css({ + overflow: 'hidden', + width: o.width, + height: o.height + }); + + if ('scrollToX' in options) + { + // jump to a static point + offset_horizontal = parseInt(o.scrollToX); + } + else if ('scrollByX' in options) + { + // jump by value pixels + offset_horizontal += parseInt(o.scrollByX); + } + if ('scrollToY' in options) { // jump to a static point - offset = parseInt(o.scrollTo); + offset_vertical = parseInt(o.scrollToY); } - else if ('scrollBy' in options) + else if ('scrollByY' in options) { // jump by value pixels - offset += parseInt(o.scrollBy); + offset_vertical += parseInt(o.scrollByY); } - else if ('destroy' in options) + + if ('destroy' in options) { // remove slimscroll elements - bar.remove(); - rail.remove(); + barX.remove(); + railX.remove(); + barY.remove(); + railY.remove(); me.unwrap(); return; } - - // scroll content by the given offset - scrollContent(offset, false, true); } + // scroll content by the given offset + scrollContent(offset_horizontal, offset_vertical, false, true); return; } @@ -154,8 +227,16 @@ } } - // optionally set height to the parent's height + //check that scroll bars are enabled + hasHorizontalScrollbar = (o.axis == 'both' || o.axis == 'x'); + hasVerticalScrollbar = (o.axis == 'both' || o.axis == 'y'); + + // optionally set height/width to the parent's height/width o.height = (o.height == 'auto') ? me.parent().height() : o.height; + o.width = (o.width == 'auto') ? me.parent().width() : o.width; + + //store options in DOM + me.data('slimScrollConfig', o); // wrap content var wrapper = $(divS) @@ -174,110 +255,281 @@ height: o.height }); - // create scrollbar rail - var rail = $(divS) - .addClass(o.railClass) - .css({ - width: o.size, - height: '100%', - position: 'absolute', - top: 0, - display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none', - 'border-radius': o.railBorderRadius, - background: o.railColor, - opacity: o.railOpacity, - zIndex: 90 + // wrap it + me.wrap(wrapper); + + + if(hasHorizontalScrollbar){ + // if width is specified remove wrapping from text + if(o.width != 'auto' && hasHorizontalScrollbar){ + me.css({'white-space': 'nowrap'}); + } + + // create scrollbar rail + var railX = $(divS) + .addClass(o.railClassX) + .css({ + width: '100%', + height: o.size, + position: 'absolute', + left: 0, + display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none', + 'border-radius': o.railBorderRadius, + background: o.railColor, + opacity: o.railOpacity, + zIndex: 90 + }); + + // create scrollbar + var barX = $(divS) + .addClass(o.barClassX) + .css({ + background: o.color, + height: o.size, + position: 'absolute', + left: 0, + opacity: o.opacity, + display: o.alwaysVisible ? 'block' : 'none', + 'border-radius' : o.borderRadius, + BorderRadius: o.borderRadius, + MozBorderRadius: o.borderRadius, + WebkitBorderRadius: o.borderRadius, + zIndex: 99 + }); + + // set position + var xPosCss = (o.positionX == 'top') ? { top: o.distance } : { bottom: o.distance }; + railX.css(xPosCss); + barX.css(xPosCss); + + // append to parent div + me.parent().append(barX); + me.parent().append(railX); + + // make it draggable and no longer dependent on the jqueryUI + if(o.railDraggable){ + barX.on("mousedown", function(e) { + isDragg = true; + t = parseFloat(barX.css('left')); + pageX = e.pageX; + + $doc.on("mousemove.slimscrollX", function(e){ + currLeft = t + e.pageX - pageX; + barX.css('left', currLeft); + scrollContent(0, 0, barX.position().left);// scroll content + }); + + $doc.on("mouseup.slimscrollX", function(e) { + isDragg = false; + hideBarX(); + $doc.unbind('.slimscrollX'); + }); + return false; + }).on("selectstart.slimscrollX", function(e){ + e.stopPropagation(); + e.preventDefault(); + return false; + }); + + railX.on("mousedown", function(e){ + var deltaX = (e.offsetX - (barWidth/2))* me[0].scrollWidth / me.outerWidth(); + scrollContent(deltaX, 0, false, true);// scroll content + t = parseFloat(barX.css('left')); + pageX = e.pageX; + + $doc.on("mousemove.slimscrollX", function(e){ + currLeft = t + e.pageX - pageX; + barX.css('left', currLeft); + scrollContent(0, 0, barX.position().left);// scroll content + }); + + $doc.on("mouseup.slimscrollX", function(e) { + isDragg = false; + hideBarX(); + $doc.unbind('.slimscrollX'); + }); + return false; + }); + } + + // on rail over + railX.hover(function(){ + showBarX(); + }, function(){ + hideBarX(); }); - // create scrollbar - var bar = $(divS) - .addClass(o.barClass) - .css({ - background: o.color, - width: o.size, - position: 'absolute', - top: 0, - opacity: o.opacity, - display: o.alwaysVisible ? 'block' : 'none', - 'border-radius' : o.borderRadius, - BorderRadius: o.borderRadius, - MozBorderRadius: o.borderRadius, - WebkitBorderRadius: o.borderRadius, - zIndex: 99 + // on bar over + barX.hover(function(){ + isOverBarX = true; + }, function(){ + isOverBarX = false; }); - // set position - var posCss = (o.position == 'right') ? { right: o.distance } : { left: o.distance }; - rail.css(posCss); - bar.css(posCss); + // set up initial width and height + getBarXWidth(); - // wrap it - me.wrap(wrapper); + // check start position + if (o.startX === 'right') + { + // scroll content to rigth + barX.css({ left: me.outerWidth() - barX.outerWidth() }); + scrollContent(0, 0, true); + } + else if (o.startX !== 'left') + { + // assume jQuery selector + scrollContent($(o.startX).position().left, null, null, true); + + // make sure bar stays hidden + if (!o.alwaysVisible) { barX.hide(); } + } + + } - // append to parent div - me.parent().append(bar); - me.parent().append(rail); - - // make it draggable and no longer dependent on the jqueryUI - if (o.railDraggable){ - bar.bind("mousedown", function(e) { - var $doc = $(document); - isDragg = true; - t = parseFloat(bar.css('top')); - pageY = e.pageY; - - $doc.bind("mousemove.slimscroll", function(e){ - currTop = t + e.pageY - pageY; - bar.css('top', currTop); - scrollContent(0, bar.position().top, false);// scroll content + + if(hasVerticalScrollbar){ + // create scrollbar rail + var railY = $(divS) + .addClass(o.railClassY) + .css({ + width: o.size, + height: '100%', + position: 'absolute', + top: 0, + display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none', + 'border-radius': o.railBorderRadius, + background: o.railColor, + opacity: o.railOpacity, + zIndex: 90 }); - $doc.bind("mouseup.slimscroll", function(e) { - isDragg = false;hideBar(); - $doc.unbind('.slimscroll'); + // create scrollbar + var barY = $(divS) + .addClass(o.barClassY) + .css({ + background: o.color, + width: o.size, + position: 'absolute', + top: 0, + opacity: o.opacity, + display: o.alwaysVisible ? 'block' : 'none', + 'border-radius' : o.borderRadius, + BorderRadius: o.borderRadius, + MozBorderRadius: o.borderRadius, + WebkitBorderRadius: o.borderRadius, + zIndex: 99 }); - return false; - }).bind("selectstart.slimscroll", function(e){ - e.stopPropagation(); - e.preventDefault(); - return false; + + var yPosCss = (o.positionY == 'right') ? { right: o.distance } : { left: o.distance }; + railY.css(yPosCss); + barY.css(yPosCss); + + me.parent().append(barY); + me.parent().append(railY); + + if(o.railDraggable){ + barY.on("mousedown", function(e) { + isDragg = true; + t = parseFloat(barY.css('top')); + pageY = e.pageY; + + $doc.on("mousemove.slimscrollY", function(e){ + currTop = t + e.pageY - pageY; + barY.css('top', currTop); + scrollContent(0, 0, barY.position().top);// scroll content + }); + + $doc.on("mouseup.slimscrollY", function(e) { + isDragg = false; + hideBarY(); + $doc.unbind('.slimscrollY'); + }); + return false; + }).on("selectstart.slimscrollY", function(e){ + e.stopPropagation(); + e.preventDefault(); + return false; + }); + + railY.on("mousedown", function(e){ + var deltaY = (e.offsetY - (barHeight/2))* me[0].scrollHeight / me.outerHeight(); + scrollContent(0, deltaY, false, true);// scroll content + t = parseFloat(barY.css('top')); + pageY = e.pageY; + + $doc.on("mousemove.slimscrollY", function(e){ + currTop = t + e.pageY - pageY; + barY.css('top', currTop); + scrollContent(0, 0, barY.position().top);// scroll content + }); + + $doc.on("mouseup.slimscrollY", function(e) { + isDragg = false; + hideBarY(); + $doc.unbind('.slimscrollY'); + }); + return false; + }); + } + + // on rail over + railY.hover(function(){ + showBarY(); + }, function(){ + hideBarY(); }); - } - // on rail over - rail.hover(function(){ - showBar(); - }, function(){ - hideBar(); - }); + // on bar over + barY.hover(function(){ + isOverBarY = true; + }, function(){ + isOverBarY = false; + }); - // on bar over - bar.hover(function(){ - isOverBar = true; - }, function(){ - isOverBar = false; - }); + getBarYHeight(); + + if (o.startY === 'bottom') + { + // scroll content to bottom + barY.css({ top: me.outerHeight() - barY.outerHeight() }); + scrollContent(0, 0, true); + } + else if (o.startY !== 'top') + { + // assume jQuery selector + scrollContent(null, $(o.startY).position().top, null, true); + + // make sure bar stays hidden + if (!o.alwaysVisible) { barY.hide(); } + } + + } // show on parent mouseover me.hover(function(){ isOverPanel = true; - showBar(); - hideBar(); + showBarX(); + showBarY(); + hideBarX(); + hideBarY(); }, function(){ isOverPanel = false; - hideBar(); + hideBarX(); + hideBarY(); }); // support for mobile - me.bind('touchstart', function(e,b){ + me.on('touchstart', function(e,b){ if (e.originalEvent.touches.length) { // record where touch started - touchDif = e.originalEvent.touches[0].pageY; + touchDifX = e.originalEvent.touches[0].pageX; + touchDifY = e.originalEvent.touches[0].pageY; } }); - me.bind('touchmove', function(e){ + me.on('touchmove', function(e){ // prevent scrolling the page if necessary if(!releaseScroll) { @@ -286,154 +538,301 @@ if (e.originalEvent.touches.length) { // see how far user swiped - var diff = (touchDif - e.originalEvent.touches[0].pageY) / o.touchScrollStep; + var diffX = (touchDifX - e.originalEvent.touches[0].pageX) / o.touchScrollStep; + var diffY = (touchDifY - e.originalEvent.touches[0].pageY) / o.touchScrollStep; // scroll content - scrollContent(diff, true); - touchDif = e.originalEvent.touches[0].pageY; + scrollContent(diffX, diffY, true); + touchDifX = e.originalEvent.touches[0].pageX; + touchDifY = e.originalEvent.touches[0].pageY; } }); - // set up initial height - getBarHeight(); - - // check start position - if (o.start === 'bottom') - { - // scroll content to bottom - bar.css({ top: me.outerHeight() - bar.outerHeight() }); - scrollContent(0, true); - } - else if (o.start !== 'top') - { - // assume jQuery selector - scrollContent($(o.start).position().top, null, true); - - // make sure bar stays hidden - if (!o.alwaysVisible) { bar.hide(); } - } // attach scroll events attachWheel(this); + function _getDeltaFromEvent(e) { + var deltaX = 0; + var deltaY = 0; + + // Old school scrollwheel delta + if ( 'detail' in e ) { deltaY = e.detail; } + if ( 'wheelDelta' in e ) { deltaY = -1 * e.wheelDelta / 6; } + if ( 'wheelDeltaY' in e ) { deltaY = -1 * e.wheelDeltaY / 6; } + if ( 'wheelDeltaX' in e ) { deltaX = e.wheelDeltaX / 6; } + + // Firefox < 17 horizontal scrolling related to DOMMouseScroll event + if ( 'axis' in e && e.axis === e.HORIZONTAL_AXIS ) { + deltaX = deltaY * -1; + deltaY = 0; + } + + if (deltaX !== deltaX && deltaY !== deltaY/* NaN checks */) { + // IE in some mouse drivers + deltaX = 0; + deltaY = e.wheelDelta; + } + + // New school wheel delta (wheel event) + if ( 'deltaY' in e ) { + deltaY = e.deltaY; + } + if ( 'deltaX' in e ) { + deltaX = e.deltaX; + } + + return [deltaX, deltaY]; + } + function _onWheel(e) { // use mouse wheel only when mouse is over if (!isOverPanel) { return; } - var e = e || window.event; + e = e || window.event; - var delta = 0; - if (e.wheelDelta) { delta = -e.wheelDelta/120; } - if (e.detail) { delta = e.detail / 3; } + var delta = _getDeltaFromEvent(e); + var deltaX = delta[0]; + var deltaY = delta[1]; + + // if (e.wheelDelta) { delta = -e.wheelDelta/120; } + // if (e.detail) { delta = e.detail / 3; } var target = e.target || e.srcTarget || e.srcElement; if ($(target).closest('.' + o.wrapperClass).is(me.parent())) { // scroll content - scrollContent(delta, true); + scrollContent(deltaX, deltaY, true); } // stop window scroll - if (e.preventDefault && !releaseScroll) { e.preventDefault(); } + if (e.preventDefault && !releaseScroll) { + e.preventDefault(); + e.stopPropagation(); + } if (!releaseScroll) { e.returnValue = false; } } - function scrollContent(y, isWheel, isJump) + function scrollContent(x, y, isWheel, isJump) { releaseScroll = false; - var delta = y; - var maxTop = me.outerHeight() - bar.outerHeight(); - if (isWheel) - { - // move bar with mouse wheel - delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight(); + if(hasHorizontalScrollbar){ + var deltaX = moveFactor = x; + if(o.applyVerticalWheelToHorizontal && o.axis == 'x' && !deltaX && !!y){ + deltaX = moveFactor = y; + } + var maxLeft = me.outerWidth() - barX.outerWidth(); + + if (isWheel) + { + // move bar with mouse wheel + deltaX = parseInt(barX.css('left')) + (moveFactor * parseInt(o.wheelStep)/100); - // move bar, make sure it doesn't go out - delta = Math.min(Math.max(delta, 0), maxTop); + // move bar, make sure it doesn't go out + deltaX = Math.min(Math.max(deltaX, 0), maxLeft); - // if scrolling down, make sure a fractional change to the - // scroll position isn't rounded away when the scrollbar's CSS is set - // this flooring of delta would happened automatically when - // bar.css is set below, but we floor here for clarity - delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta); + // if scrolling right, make sure a fractional change to the + // scroll position isn't rounded away when the scrollbar's CSS is set + // this flooring of delta would happened automatically when + // bar.css is set below, but we floor here for clarity + deltaX = (moveFactor > 0) ? Math.ceil(deltaX) : Math.floor(deltaX); - // scroll the scrollbar - bar.css({ top: delta + 'px' }); - } + // scroll the scrollbar + barX.css({ left: deltaX + 'px' }); + } - // calculate actual scroll amount - percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight()); - delta = percentScroll * (me[0].scrollHeight - me.outerHeight()); + // calculate actual scroll amount + percentScrollX = parseInt(barX.css('left')) / (me.outerWidth() - barX.outerWidth()); + deltaX = percentScrollX * (me[0].scrollWidth - me.outerWidth()); - if (isJump) - { - delta = y; - var offsetTop = delta / me[0].scrollHeight * me.outerHeight(); - offsetTop = Math.min(Math.max(offsetTop, 0), maxTop); - bar.css({ top: offsetTop + 'px' }); + if (isJump) + { + deltaX = x; + var offsetLeft = deltaX / me[0].scrollWidth * me.outerWidth(); + offsetLeft = Math.min(Math.max(offsetLeft, 0), maxLeft); + barX.css({ left: offsetLeft + 'px' }); + } + + // scroll content and fire scrolling event + me.scrollLeft(deltaX); + me.trigger('slimscrollingX', ~~deltaX); + + // ensure bar is visible + showBarX(); + + // trigger hide when scroll is stopped + hideBarX(); } - // scroll content - me.scrollTop(delta); - // fire scrolling event - me.trigger('slimscrolling', ~~delta); + if(hasVerticalScrollbar){ + var deltaY = y; + var maxTop = me.outerHeight() - barY.outerHeight(); + + if (isWheel) + { + // move bar with mouse wheel + deltaY = parseInt(barY.css('top')) + (y * parseInt(o.wheelStep) /100); + + // move bar, make sure it doesn't go out + deltaY = Math.min(Math.max(deltaY, 0), maxTop); + + // if scrolling down, make sure a fractional change to the + // scroll position isn't rounded away when the scrollbar's CSS is set + // this flooring of delta would happened automatically when + // bar.css is set below, but we floor here for clarity + deltaY = (y > 0) ? Math.ceil(deltaY) : Math.floor(deltaY); + + // scroll the scrollbar + barY.css({ top: deltaY + 'px' }); + } + + // calculate actual scroll amount + percentScrollY = parseInt(barY.css('top')) / (me.outerHeight() - barY.outerHeight()); + deltaY = percentScrollY * (me[0].scrollHeight - me.outerHeight()); + + if (isJump) + { + deltaY = y; + var offsetTop = deltaY / me[0].scrollHeight * me.outerHeight(); + offsetTop = Math.min(Math.max(offsetTop, 0), maxTop); + barY.css({ top: offsetTop + 'px' }); + } + + // scroll content and fire scrolling event + me.scrollTop(deltaY); + me.trigger('slimscrollingY', ~~deltaY); - // ensure bar is visible - showBar(); + // ensure bar is visible + showBarY(); + + // trigger hide when scroll is stopped + hideBarY(); + } - // trigger hide when scroll is stopped - hideBar(); } function attachWheel(target) { if (window.addEventListener) { + if (typeof window.onwheel !== "undefined") { + target.addEventListener('wheel', _onWheel, false ); + } else if (typeof window.onmousewheel !== "undefined") { + target.addEventListener('mousewheel', _onWheel, false ); + } target.addEventListener('DOMMouseScroll', _onWheel, false ); - target.addEventListener('mousewheel', _onWheel, false ); } else { - document.attachEvent("onmousewheel", _onWheel) + document.attachEvent("onmousewheel", _onWheel); } } - function getBarHeight() + function getBarXWidth() + { + if(!barX){return;} + // calculate scrollbar height and make sure it is not too small + barWidth = Math.max((me.outerWidth() / me[0].scrollWidth) * me.outerWidth(), minBarWidth); + barX.css({ width: barWidth + 'px' }); + + // hide scrollbar if content is not long enough + // var display = barWidth == me.outerWidth() ? 'none' : 'block'; + var display = (hasHorizontalScrollbar && (me[0].scrollWidth>me[0].clientWidth)) ? 'block' : 'none'; + barX.css({ display: display }); + } + + function getBarYHeight() { + if(!barY){return;} // calculate scrollbar height and make sure it is not too small barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight); - bar.css({ height: barHeight + 'px' }); + barY.css({ height: barHeight + 'px' }); // hide scrollbar if content is not long enough - var display = barHeight == me.outerHeight() ? 'none' : 'block'; - bar.css({ display: display }); + // var display = barHeight == me.outerHeight() ? 'none' : 'block'; + var display = (hasVerticalScrollbar && (me[0].scrollHeight>me[0].clientHeight)) ? 'block' : 'none'; + barY.css({ display: display }); + } + + + function showBarX() + { + if(!barX){return;} + // recalculate bar height + getBarXWidth(); + clearTimeout(queueHideX); + + // when bar reached top or bottom + if (percentScrollX == ~~percentScrollX) + { + //release wheel + releaseScroll = o.allowPageScroll; + + // publish approporiate event + if (lastScrollX != percentScrollX) + { + var msg = (~~percentScrollX === 0) ? 'left' : 'right'; + me.trigger('slimscrollX', msg); + } + } + else + { + releaseScroll = false; + } + lastScrollX = percentScrollX; + + // show only when required + if(barWidth >= me.outerWidth()) { + //allow window scroll + releaseScroll = true; + return; + } + barX.stop(true,true).fadeIn('fast'); + if (o.railVisible) { railX.stop(true,true).fadeIn('fast'); } + } + + function hideBarX() + { + if(!barX){return;} + // only hide when options allow it + if (!o.alwaysVisible) + { + queueHideX = setTimeout(function(){ + if (!(o.disableFadeOut && isOverPanel) && !isOverBarX && !isDragg) + { + barX.fadeOut('slow'); + railX.fadeOut('slow'); + } + }, 1000); + } } - function showBar() + function showBarY() { + if(!barY){return;} // recalculate bar height - getBarHeight(); - clearTimeout(queueHide); + getBarYHeight(); + clearTimeout(queueHideY); // when bar reached top or bottom - if (percentScroll == ~~percentScroll) + if (percentScrollY == ~~percentScrollY) { //release wheel releaseScroll = o.allowPageScroll; // publish approporiate event - if (lastScroll != percentScroll) + if (lastScrollY != percentScrollY) { - var msg = (~~percentScroll == 0) ? 'top' : 'bottom'; - me.trigger('slimscroll', msg); + var msg = (~~percentScrollY === 0) ? 'top' : 'bottom'; + me.trigger('slimscrollY', msg); } } else { releaseScroll = false; } - lastScroll = percentScroll; + lastScrollY = percentScrollY; // show only when required if(barHeight >= me.outerHeight()) { @@ -441,20 +840,21 @@ releaseScroll = true; return; } - bar.stop(true,true).fadeIn('fast'); - if (o.railVisible) { rail.stop(true,true).fadeIn('fast'); } + barY.stop(true,true).fadeIn('fast'); + if (o.railVisible) { railY.stop(true,true).fadeIn('fast'); } } - function hideBar() + function hideBarY() { + if(!barY){return;} // only hide when options allow it if (!o.alwaysVisible) { - queueHide = setTimeout(function(){ - if (!(o.disableFadeOut && isOverPanel) && !isOverBar && !isDragg) + queueHideY = setTimeout(function(){ + if (!(o.disableFadeOut && isOverPanel) && !isOverBarY && !isDragg) { - bar.fadeOut('slow'); - rail.fadeOut('slow'); + barY.fadeOut('slow'); + railY.fadeOut('slow'); } }, 1000); } @@ -462,6 +862,8 @@ }); + this.trigger('initialized'); + // maintain chainability return this; } diff --git a/jquery.slimscroll.min.js b/jquery.slimscroll.min.js index decf42f..cd5ea8b 100644 --- a/jquery.slimscroll.min.js +++ b/jquery.slimscroll.min.js @@ -1,16 +1 @@ -/*! 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. - * - * Version: 1.3.7 - * - */ -(function(e){e.fn.extend({slimScroll:function(f){var a=e.extend({width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},f);this.each(function(){function v(d){if(r){d=d||window.event; -var c=0;d.wheelDelta&&(c=-d.wheelDelta/120);d.detail&&(c=d.detail/3);e(d.target||d.srcTarget||d.srcElement).closest("."+a.wrapperClass).is(b.parent())&&n(c,!0);d.preventDefault&&!k&&d.preventDefault();k||(d.returnValue=!1)}}function n(d,e,f){k=!1;var g=d,h=b.outerHeight()-c.outerHeight();e&&(g=parseInt(c.css("top"))+d*parseInt(a.wheelStep)/100*c.outerHeight(),g=Math.min(Math.max(g,0),h),g=0=b.outerHeight()?k=!0:(c.stop(!0, -!0).fadeIn("fast"),a.railVisible&&m.stop(!0,!0).fadeIn("fast"))}function q(){a.alwaysVisible||(B=setTimeout(function(){a.disableFadeOut&&r||y||z||(c.fadeOut("slow"),m.fadeOut("slow"))},1E3))}var r,y,z,B,A,u,l,C,k=!1,b=e(this);if(b.parent().hasClass(a.wrapperClass)){var p=b.scrollTop(),c=b.siblings("."+a.barClass),m=b.siblings("."+a.railClass);x();if(e.isPlainObject(f)){if("height"in f&&"auto"==f.height){b.parent().css("height","auto");b.css("height","auto");var h=b.parent().parent().height();b.parent().css("height", -h);b.css("height",h)}else"height"in f&&(h=f.height,b.parent().css("height",h),b.css("height",h));if("scrollTo"in f)p=parseInt(a.scrollTo);else if("scrollBy"in f)p+=parseInt(a.scrollBy);else if("destroy"in f){c.remove();m.remove();b.unwrap();return}n(p,!1,!0)}}else if(!(e.isPlainObject(f)&&"destroy"in f)){a.height="auto"==a.height?b.parent().height():a.height;p=e("
    ").addClass(a.wrapperClass).css({position:"relative",overflow:"hidden",width:a.width,height:a.height});b.css({overflow:"hidden", -width:a.width,height:a.height});var m=e("
    ").addClass(a.railClass).css({width:a.size,height:"100%",position:"absolute",top:0,display:a.alwaysVisible&&a.railVisible?"block":"none","border-radius":a.railBorderRadius,background:a.railColor,opacity:a.railOpacity,zIndex:90}),c=e("
    ").addClass(a.barClass).css({background:a.color,width:a.size,position:"absolute",top:0,opacity:a.opacity,display:a.alwaysVisible?"block":"none","border-radius":a.borderRadius,BorderRadius:a.borderRadius,MozBorderRadius:a.borderRadius, -WebkitBorderRadius:a.borderRadius,zIndex:99}),h="right"==a.position?{right:a.distance}:{left:a.distance};m.css(h);c.css(h);b.wrap(p);b.parent().append(c);b.parent().append(m);a.railDraggable&&c.bind("mousedown",function(a){var b=e(document);z=!0;t=parseFloat(c.css("top"));pageY=a.pageY;b.bind("mousemove.slimscroll",function(a){currTop=t+a.pageY-pageY;c.css("top",currTop);n(0,c.position().top,!1)});b.bind("mouseup.slimscroll",function(a){z=!1;q();b.unbind(".slimscroll")});return!1}).bind("selectstart.slimscroll", -function(a){a.stopPropagation();a.preventDefault();return!1});m.hover(function(){w()},function(){q()});c.hover(function(){y=!0},function(){y=!1});b.hover(function(){r=!0;w();q()},function(){r=!1;q()});b.bind("touchstart",function(a,b){a.originalEvent.touches.length&&(A=a.originalEvent.touches[0].pageY)});b.bind("touchmove",function(b){k||b.originalEvent.preventDefault();b.originalEvent.touches.length&&(n((A-b.originalEvent.touches[0].pageY)/a.touchScrollStep,!0),A=b.originalEvent.touches[0].pageY)}); -x();"bottom"===a.start?(c.css({top:b.outerHeight()-c.outerHeight()}),n(0,!0)):"top"!==a.start&&(n(e(a.start).position().top,null,!0),a.alwaysVisible||c.hide());window.addEventListener?(this.addEventListener("DOMMouseScroll",v,!1),this.addEventListener("mousewheel",v,!1)):document.attachEvent("onmousewheel",v)}});return this}});e.fn.extend({slimscroll:e.fn.slimScroll})})(jQuery); \ No newline at end of file +!function(t){t.fn.extend({slimScroll:function(i){var e={axis:"y",width:"auto",height:"250px",size:"7px",color:"#000",positionX:"bottom",positionY:"right",distance:"1px",startX:"left",startY:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClassX:"slimScrollRailX",barClassX:"slimScrollBarX",railClassY:"slimScrollRailY",barClassY:"slimScrollBarY",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},o=t.extend(e,i);return o.axis=o.axis.toLowerCase(),this.each(function(){function e(t){var i=0,e=0;return"detail"in t&&(e=t.detail),"wheelDelta"in t&&(e=-1*t.wheelDelta/6),"wheelDeltaY"in t&&(e=-1*t.wheelDeltaY/6),"wheelDeltaX"in t&&(i=t.wheelDeltaX/6),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(i=-1*e,e=0),i!==i&&e!==e&&(i=0,e=t.wheelDelta),"deltaY"in t&&(e=t.deltaY),"deltaX"in t&&(i=t.deltaX),[i,e]}function s(i){if(m){i=i||window.event;var s=e(i),a=s[0],r=s[1],n=i.target||i.srcTarget||i.srcElement;t(n).closest("."+o.wrapperClass).is(E.parent())&&l(a,r,!0),i.preventDefault&&!V&&i.preventDefault(),V||(i.returnValue=!1)}}function l(t,i,e,s){if(V=!1,p){var l=t,a=E.outerWidth()-j.outerWidth();if(e&&(l=parseInt(j.css("left"))+t*parseInt(o.wheelStep)/100,l=Math.min(Math.max(l,0),a),l=t>0?Math.ceil(l):Math.floor(l),j.css({left:l+"px"})),W=parseInt(j.css("left"))/(E.outerWidth()-j.outerWidth()),l=W*(E[0].scrollWidth-E.outerWidth()),s){l=t;var r=l/E[0].scrollWidth*E.outerWidth();r=Math.min(Math.max(r,0),a),j.css({left:r+"px"})}E.scrollLeft(l),E.trigger("slimscrollingX",~~l),c(),u()}if(f){var n=i,g=E.outerHeight()-Q.outerHeight();if(e&&(n=parseInt(Q.css("top"))+i*parseInt(o.wheelStep)/100,n=Math.min(Math.max(n,0),g),n=i>0?Math.ceil(n):Math.floor(n),Q.css({top:n+"px"})),M=parseInt(Q.css("top"))/(E.outerHeight()-Q.outerHeight()),n=M*(E[0].scrollHeight-E.outerHeight()),s){n=i;var w=n/E[0].scrollHeight*E.outerHeight();w=Math.min(Math.max(w,0),g),Q.css({top:w+"px"})}E.scrollTop(n),E.trigger("slimscrollingY",~~n),d(),h()}}function a(t){window.addEventListener?(t.addEventListener("DOMMouseScroll",s,!1),t.addEventListener("mousewheel",s,!1)):document.attachEvent("onmousewheel",s)}function r(){if(j){I=Math.max(E.outerWidth()/E[0].scrollWidth*E.outerWidth(),O),j.css({width:I+"px"});var t=p&&E[0].scrollWidth>E[0].clientWidth?"block":"none";j.css({display:t})}}function n(){if(Q){R=Math.max(E.outerHeight()/E[0].scrollHeight*E.outerHeight(),B),Q.css({height:R+"px"});var t=f&&E[0].scrollHeight>E[0].clientHeight?"block":"none";Q.css({display:t})}}function c(){if(j){if(r(),clearTimeout(Y),W==~~W){if(V=o.allowPageScroll,H!=W){var t=0===~~W?"left":"right";E.trigger("slimscrollX",t)}}else V=!1;if(H=W,I>=E.outerWidth())return void(V=!0);j.stop(!0,!0).fadeIn("fast"),o.railVisible&&P.stop(!0,!0).fadeIn("fast")}}function u(){j&&(o.alwaysVisible||(Y=setTimeout(function(){o.disableFadeOut&&m||v||X||(j.fadeOut("slow"),P.fadeOut("slow"))},1e3)))}function d(){if(Q){if(n(),clearTimeout(y),M==~~M){if(V=o.allowPageScroll,D!=M){var t=0===~~M?"top":"bottom";E.trigger("slimscrollY",t)}}else V=!1;if(D=M,R>=E.outerHeight())return void(V=!0);Q.stop(!0,!0).fadeIn("fast"),o.railVisible&&N.stop(!0,!0).fadeIn("fast")}}function h(){Q&&(o.alwaysVisible||(y=setTimeout(function(){o.disableFadeOut&&m||x||X||(Q.fadeOut("slow"),N.fadeOut("slow"))},1e3)))}var p,f,g,w,b,m,v,x,X,Y,y,C,S,R,I,W,H,M,D,T="
    ",B=30,O=30,V=!1,E=t(this),k=t(document);if(E.parent().hasClass(o.wrapperClass)){t.extend(o,E.data("slimScrollConfig")||{});var z=E.scrollLeft(),L=E.scrollTop();return j=E.siblings("."+o.barClassX),P=E.siblings("."+o.railClassX),Q=E.siblings("."+o.barClassY),N=E.siblings("."+o.railClassY),p="both"==o.axis||"x"==o.axis,f="both"==o.axis||"y"==o.axis,r(),n(),t.isPlainObject(i)&&("width"in i&&p&&("auto"==i.width?(E.parent().css("width","auto"),E.css("width","auto"),o.width=E.parent().parent().width()):(o.width=i.width,E.css({"white-space":"nowrap"}))),"height"in i&&f&&("auto"==i.height?(E.parent().css("height","auto"),E.css("height","auto"),o.height=E.parent().parent().height()):o.height=i.height),E.parent().css({position:"relative",overflow:"hidden",width:o.width,height:o.height}),E.css({overflow:"hidden",width:o.width,height:o.height}),"scrollToX"in i?z=parseInt(o.scrollToX):"scrollByX"in i&&(z+=parseInt(o.scrollByX)),"scrollToY"in i?L=parseInt(o.scrollToY):"scrollByY"in i&&(L+=parseInt(o.scrollByY)),"destroy"in i)?(j.remove(),P.remove(),Q.remove(),N.remove(),void E.unwrap()):void l(z,L,!1,!0)}if(!(t.isPlainObject(i)&&"destroy"in i)){p="both"==o.axis||"x"==o.axis,f="both"==o.axis||"y"==o.axis,o.height="auto"==o.height?E.parent().height():o.height,o.width="auto"==o.width?E.parent().width():o.width,E.data("slimScrollConfig",o);var F=t(T).addClass(o.wrapperClass).css({position:"relative",overflow:"hidden",width:o.width,height:o.height});if(E.css({overflow:"hidden",width:o.width,height:o.height}),E.wrap(F),p){"auto"!=o.width&&p&&E.css({"white-space":"nowrap"});var P=t(T).addClass(o.railClassX).css({width:"100%",height:o.size,position:"absolute",left:0,display:o.alwaysVisible&&o.railVisible?"block":"none","border-radius":o.railBorderRadius,background:o.railColor,opacity:o.railOpacity,zIndex:90}),j=t(T).addClass(o.barClassX).css({background:o.color,height:o.size,position:"absolute",left:0,opacity:o.opacity,display:o.alwaysVisible?"block":"none","border-radius":o.borderRadius,BorderRadius:o.borderRadius,MozBorderRadius:o.borderRadius,WebkitBorderRadius:o.borderRadius,zIndex:99}),A="top"==o.positionX?{top:o.distance}:{bottom:o.distance};P.css(A),j.css(A),E.parent().append(j),E.parent().append(P),o.railDraggable&&(j.on("mousedown",function(t){return X=!0,g=parseFloat(j.css("left")),w=t.pageX,k.on("mousemove.slimscrollX",function(t){currLeft=g+t.pageX-w,j.css("left",currLeft),l(0,0,j.position().left)}),k.on("mouseup.slimscrollX",function(t){X=!1,u(),k.unbind(".slimscrollX")}),!1}).on("selectstart.slimscrollX",function(t){return t.stopPropagation(),t.preventDefault(),!1}),P.on("mousedown",function(t){var i=(t.offsetX-I/2)*E[0].scrollWidth/E.outerWidth();return l(i,0,!1,!0),g=parseFloat(j.css("left")),w=t.pageX,k.on("mousemove.slimscrollX",function(t){currLeft=g+t.pageX-w,j.css("left",currLeft),l(0,0,j.position().left)}),k.on("mouseup.slimscrollX",function(t){X=!1,u(),k.unbind(".slimscrollX")}),!1})),P.hover(function(){c()},function(){u()}),j.hover(function(){v=!0},function(){v=!1}),r(),"right"===o.startX?(j.css({left:E.outerWidth()-j.outerWidth()}),l(0,0,!0)):"left"!==o.startX&&(l(t(o.startX).position().left,null,null,!0),o.alwaysVisible||j.hide())}if(f){var N=t(T).addClass(o.railClassY).css({width:o.size,height:"100%",position:"absolute",top:0,display:o.alwaysVisible&&o.railVisible?"block":"none","border-radius":o.railBorderRadius,background:o.railColor,opacity:o.railOpacity,zIndex:90}),Q=t(T).addClass(o.barClassY).css({background:o.color,width:o.size,position:"absolute",top:0,opacity:o.opacity,display:o.alwaysVisible?"block":"none","border-radius":o.borderRadius,BorderRadius:o.borderRadius,MozBorderRadius:o.borderRadius,WebkitBorderRadius:o.borderRadius,zIndex:99}),Z="right"==o.positionY?{right:o.distance}:{left:o.distance};N.css(Z),Q.css(Z),E.parent().append(Q),E.parent().append(N),o.railDraggable&&(Q.on("mousedown",function(t){return X=!0,g=parseFloat(Q.css("top")),b=t.pageY,k.on("mousemove.slimscrollY",function(t){currTop=g+t.pageY-b,Q.css("top",currTop),l(0,0,Q.position().top)}),k.on("mouseup.slimscrollY",function(t){X=!1,h(),k.unbind(".slimscrollY")}),!1}).on("selectstart.slimscrollY",function(t){return t.stopPropagation(),t.preventDefault(),!1}),N.on("mousedown",function(t){var i=(t.offsetY-R/2)*E[0].scrollHeight/E.outerHeight();return l(0,i,!1,!0),g=parseFloat(Q.css("top")),b=t.pageY,k.on("mousemove.slimscrollY",function(t){currTop=g+t.pageY-b,Q.css("top",currTop),l(0,0,Q.position().top)}),k.on("mouseup.slimscrollY",function(t){X=!1,h(),k.unbind(".slimscrollY")}),!1})),N.hover(function(){d()},function(){h()}),Q.hover(function(){x=!0},function(){x=!1}),n(),"bottom"===o.startY?(Q.css({top:E.outerHeight()-Q.outerHeight()}),l(0,0,!0)):"top"!==o.startY&&(l(null,t(o.startY).position().top,null,!0),o.alwaysVisible||Q.hide())}E.hover(function(){m=!0,c(),d(),u(),h()},function(){m=!1,u(),h()}),E.on("touchstart",function(t,i){t.originalEvent.touches.length&&(C=t.originalEvent.touches[0].pageX,S=t.originalEvent.touches[0].pageY)}),E.on("touchmove",function(t){if(V||t.originalEvent.preventDefault(),t.originalEvent.touches.length){var i=(C-t.originalEvent.touches[0].pageX)/o.touchScrollStep,e=(S-t.originalEvent.touches[0].pageY)/o.touchScrollStep;l(i,e,!0),C=t.originalEvent.touches[0].pageX,S=t.originalEvent.touches[0].pageY}}),a(this)}}),this}}),t.fn.extend({slimscroll:t.fn.slimScroll})}(jQuery); \ No newline at end of file diff --git a/package.json b/package.json index 4ac6ccf..af5ae4e 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,33 @@ { - "name" : "jquery-slimscroll", - "version" : "1.3.7", - "title" : "jQuery slimScroll scrollbar", - "description" : "slimScroll is a small jQuery plugin that transforms any div into a scrollable area. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over.", - "keywords" : ["scrollbar", "scroll", "slimscroll", "scrollable", "scrolling", "scroller", "ui", "jquery-plugin", "ecosystem:jquery"], - "homepage" : "http://rocha.la/jQuery-slimScroll/", + "name": "jquery-slimscroll+", + "version": "1.3.7", + "title": "jQuery slimScroll scrollbar", + "description": "slimScroll is a small jQuery plugin that transforms any div into a scrollable area. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over.", + "keywords": [ + "scrollbar", + "scroll", + "slimscroll", + "scrollable", + "scrolling", + "scroller", + "horizontal", + "ui", + "jquery-plugin", + "ecosystem:jquery" + ], + "homepage": "https://github.com/rochal/jQuery-slimScroll/", "repository": { "type": "git", "url": "https://github.com/rochal/jQuery-slimScroll.git" }, - "author" : { - "name" : "Piotr Rochala", - "url" : "http://rocha.la/" + "author": { + "name": "Piotr Rochala", + "url": "http://rocha.la/" }, - - "dependencies" : { - "jquery" : ">= 1.7" + "dependencies": { + "jquery": ">= 1.7" }, - - "licenses" : [ + "licenses": [ { "type": "MIT", "url": "http://www.opensource.org/licenses/mit-license.php" @@ -27,5 +36,15 @@ "type": "GPL", "url": "http://www.opensource.org/licenses/gpl-license.php" } - ] -} \ No newline at end of file + ], + "devDependencies": { + "gulp": "^3.9.0", + "gulp-jshint": "^2.0.0", + "gulp-rename": "^1.2.2", + "gulp-uglify": "^1.5.1", + "gulp-util": "^3.0.7", + "gulp-watch": "^4.3.5", + "jshint": "^2.8.0", + "jshint-stylish": "^2.1.0" + } +}