jquery - how to reduce the scrolling value in javascript? -


i adjust scroll value of mouse wheel.

i manipulate 400px 200px when scrolltop value 400px.

is there way?

the scroll speed can changed, adjusted, reversed, of above - via javascript (or js library such jquery).

why want this? parallax 1 of reasons. have no idea why argue against doing -- same negative arguments can made against hiding divs, sliding elements up/down, etc. websites combination of technical functionality , ux design -- designer can use technical capability improve ux. makes him/her good.

toni almeida of portugal created brilliant demo, reproduced below: see link: http://jsfiddle.net/36dp03ur/

html

<div id="mydiv">     use mouse wheel (not scroll bar) scroll div. see scroll slows down, , stops. <span class="boldit">use mouse wheel (not scroll bar) scroll div. see scroll slows down, , stops. </span> </div> 

js:

function wheel(event) {   var delta = 0;   if (event.wheeldelta) {(delta = event.wheeldelta / 120);}   else if (event.detail) {(delta = -event.detail / 3);}    handle(delta);   if (event.preventdefault) {(event.preventdefault());}   event.returnvalue = false;  }  function handle(delta) {   var time = 1000;   var distance = 300;    $('html, body').stop().animate({       scrolltop: $(window).scrolltop() - (distance * delta)   }, time );   }    if (window.addeventlistener) {window.addeventlistener('dommousescroll', wheel, false);}   window.onmousewheel = document.onmousewheel = wheel; 

source : can change scroll speed using css or jquery?


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -