Click to See Complete Forum and Search --> : How to move scrollbar automatically when i drag an item from top to bottom by mouse?
adusumalli
October 28th, 2008, 11:49 AM
Hi
I am facing problem with scrollbar when i drag and drop an item in the table from top to bottom or bottom to top. please see my attached file.
PeejAvery
October 28th, 2008, 01:39 PM
Just use window.scrollTo(x, y).
adusumalli
October 28th, 2008, 03:02 PM
where i have to use this statement : window.scrollTo(x, y).
thanks
PeejAvery
October 28th, 2008, 03:16 PM
That only tells the window to scroll.
Since you already have drag and drop capabilities, then you must have access to the mouse coordinates. If the mouse Y coordinate is about to go off the screen, tell the window to scroll up about 50 pixels.
adusumalli
November 7th, 2008, 11:17 AM
hey thanks for reply, i used like this window.scrollTo(0,5); it always move to top of the page. If i want to move in between the page how can i set the coordinates.
thanks ...
PeejAvery
November 7th, 2008, 12:03 PM
The two numbers are the X and Y coordinates of the page. Just specify the coordinates to which you want to scroll.
TheCPUWizard
November 7th, 2008, 12:05 PM
The two numbers are the X and Y coordinates of the page. Just specify the coordinates to which you want to scroll.
[Hint: usually relative to some "current" position....]
adusumalli
November 7th, 2008, 12:12 PM
The two numbers are the X and Y coordinates of the page. Just specify the coordinates to which you want to scroll.
Y coordinate every time will changed. i want to move the scroll bar based on the mouse like we scroll the mouse up and down. Like that when i drag the selected element with mouse it should move scrollbar with the mouse.
thanks..
PeejAvery
November 7th, 2008, 12:40 PM
[Hint: usually relative to some "current" position....]
Not in JavaScript. It is always from the top of the page. The offset is always controlled by scrolling offset methods.
Y coordinate every time will changed. i want to move the scroll bar based on the mouse like we scroll the mouse up and down. Like that when i drag the selected element with mouse it should move scrollbar with the mouse.
So why not just track the mouse coordinates and then set the scrollTo accordingly?
TheCPUWizard
November 7th, 2008, 12:43 PM
Not in JavaScript. It is always from the top of the page. The offset is always controlled by scrolling offset methods.
So why not just track the mouse coordinates and then set the scrollTo accordingly?
The parameter to ScrollTo() is always absolute...no disagreement...
HOW those parameters are CALCULATED is usually based on a combintation of the current position and the desired amount of movement (A "relative" value).
adusumalli
November 7th, 2008, 05:16 PM
hey thanks. Now it's working .
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.