CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2008
    Posts
    142

    How to move scrollbar automatically when i drag an item from top to bottom by mouse?

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mouse?

    Just use window.scrollTo(x, y).
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jun 2008
    Posts
    142

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mouse?

    where i have to use this statement : window.scrollTo(x, y).


    thanks

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mouse?

    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.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jun 2008
    Posts
    142

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    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 ...

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    The two numbers are the X and Y coordinates of the page. Just specify the coordinates to which you want to scroll.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    Quote Originally Posted by PeejAvery View Post
    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....]
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  8. #8
    Join Date
    Jun 2008
    Posts
    142

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    Quote Originally Posted by PeejAvery View Post
    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..

  9. #9
    Join Date
    May 2002
    Posts
    10,943

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    Quote Originally Posted by TheCPUWizard View Post
    [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.

    Quote Originally Posted by adusumalli
    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?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  10. #10
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    Quote Originally Posted by PeejAvery View Post
    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).
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  11. #11
    Join Date
    Jun 2008
    Posts
    142

    Re: How to move scrollbar automatically when i drag an item from top to bottom by mou

    hey thanks. Now it's working .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured