Skip to content

Commit

Permalink
Add an 'autoHide' option (same as osx behaviour)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Grsmto committed Jun 17, 2013
1 parent f61444a commit 060d26f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ By default TrackpadScrollEmulator requires minimal markup, as shown above. When

Default value is `true`

####autoHide

By default TrackpadScrollEmulator has default osx behaviour that automatically hide scrollbar if user is not scrolling. But as osx, you have the option to disable it if you find hard to know if content is scrollable or not.

Default value is `true`

###Notifying the plugin of content changes

If you later dynamically modify your content, for instance changing its height or width, or adding or removing content, you should recalculate the scrollbars like so:
Expand Down
11 changes: 10 additions & 1 deletion js/jquery.trackpad-scroll-emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
$scrollContentEl.on('scroll', onScrolled);

resizeScrollbar();

if (!options.autoHide) {
showScrollbar();
}
}

/**
Expand Down Expand Up @@ -167,6 +171,10 @@
*/
function showScrollbar() {
$dragHandleEl.addClass('visible');

if (!options.autoHide) {
return;
}
if(typeof flashTimeout === 'number') {
window.clearTimeout(flashTimeout);
}
Expand Down Expand Up @@ -297,7 +305,8 @@
$.fn[pluginName].defaults = {
onInit: function() {},
onDestroy: function() {},
wrapContent: true
wrapContent: true,
autoHide: true
};

})(jQuery);

0 comments on commit 060d26f

Please sign in to comment.