javascript - scroll up/down when button is hold clicked -
javascript - scroll up/down when button is hold clicked -
please check , want content should scrolled up/ downwards ,event when text hold clicked http://liveweave.com/0m3zqq
(function () { var scrolled = 10; $('#scrollup').click(function() { $(".sidebar-menu").animate({ scrolltop: $(".sidebar-menu").scrolltop() - scrolled }); }); $('#scrolldown').click(function() { $(".sidebar-menu").animate({ scrolltop: $(".sidebar-menu").scrolltop() + scrolled }); }); })();
you can utilize combination of mousedown
, mouseup
events:
$('#scrollup').on({ 'mousedown touchstart': function () { $(".sidebar-menu").animate({scrolltop: 0}, 2000); }, 'mouseup touchend': function () { $(".sidebar-menu").stop(true); } }); $('#scrolldown').on({ 'mousedown touchstart': function () { $(".sidebar-menu").animate({ scrolltop: $(".sidebar-menu")[0].scrollheight }, 2000); }, 'mouseup touchend': function () { $(".sidebar-menu").stop(true); } });
also added touch events.
demo: http://liveweave.com/j73xmq javascript jquery
Comments
Post a Comment