Log in

View Full Version : simple div scroll using jquery



jayapalchandran
12-16-2009, 06:23 AM
i have a div with fixed height.
i use dwscroll.
it has many include files.
when i use jquery animatins this dwscroll is not working but without the animations it works.
so i need a simple jquery script which will scroll up or dowm according to the up/down button i click.
i thought there should an option in jquery for that besides scrollTo option.

jscheuer1
12-16-2009, 08:09 AM
Not sure what you mean by 'dwscroll'. Is this a script that has a demo page, or something that comes with Dreamweaver, or what?

If it is a script with a demo page, please provide a link to the dwscroll demo page.

Also - provide links to pages on your site that are using dwscroll, one where it works, one where it is conflicting with jQuery.

jayapalchandran
12-17-2009, 12:56 PM
http://www.dyn-web.com/code/scroll/documentation.php

Dw_scroll is a javascript snippet which has various functionality to scroll an element with showing the browsers default scroll bar. it has functionality like detecting mouse wheel ...

when i used this the page will not scroll and that is the default action for all elements if there is content to scroll. i mean that when the focus is in an element which has overflowed content then using the mouse wheel will not scroll the window it will just scrolls that element... sorry, you already know this.

but the most important point is that when you use flash products which does some animation in the site... it supresses the mouse wheel scroll and the focus is always to the flash object.... if you scroll anywhere on the page it wont scroll the window instead the flash will get the wheel events...
so i used the following code... to override it... (basically i do not know much about object tags focus and wheel events especially flash... may be that is the way it would have been coded)...

i dont want to manipulate dwscroll instead i was trying for a new script which will scroll the window irrespective of the current focus...

then i used jquery scrollTop option which comes with the animate effect....
and now it is working.

the code is...



var nou=0;

$('html,body').mousewheel(function(event, delta) {

if (delta > 0)
{
nou = $('html, body').scrollTop()
nou-=50

$('html, body').animate({scrollTop: nou}, 0);
}
else if (delta < 0)
{
nou = $('html, body').scrollTop()
nou+=50

$('html, body').animate({scrollTop: nou}, 0);
}

});



i dont want the animation so i made the animation duration to zero and as espected it works like the normal window scroll...

but... i hope the scroll is triggered twice... by the default scroll event and by this jquery scroller.... though that could be the case ain't much difference...


if you have any other more robust or effective standard alternate then please you can consider dropping that here...

seraulu1
03-03-2010, 01:25 PM
Thanks for that! how to hypnotize someone (http://theartofcoverthypnosis.com/)

jayapalchandran
03-03-2010, 05:34 PM
and then i wrote my own simple sleek baby scroller.
http://vikku.info/codetrash/Scroll_DIV,_HTML_elements_using_Javascript
this is just for an instance... i still have to upgrade it.