1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    63
    Vote Rating
    2
    scheid is on a distinguished road

      0  

    Default get current scroll/drag position of sencha touch panel

    get current scroll/drag position of sencha touch panel


    Hi All,

    I'm using Sencha Touch 2. I am using a panel set to be scrollable vertically, and need to be able to get the current scroll position of the panel. I explored the Ext.scroll.View object returned from getScrollable(), and also Ext.scroll.Scroller but they don't seem to have a method to get current position, that I could find.

    Looking in firebug at the object returned from getScrollable(), I did actually find a variable in there that gives me what I want, but it looks like it's intended to be private. It would be called like this ('myPanel' is just the panel instance):

    myPanel.getScrollable()._scroller.lastDragPosition

    that call returns an object with 'x' and 'y' members, which is perfect for my purposes.

    Is this the best way to get the scroll position or is there a more supported way?

    Thanks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    853
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    That could work but instead of getting the scroller via _scroller you should do getScroller()
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    63
    Vote Rating
    2
    scheid is on a distinguished road

      2  

    Default


    yep, thanks. That works.

    Also, for anyone else interested in this, I figured out that 'lastDragPosition' is just the position the scroller was at when you released your finger, which is usually different than the final resting position. For the final resting position, it's just 'position', like:

    myPanel.getScrollable().getScroller().position.x
    myPanel.getScrollable().getScroller().position.y

Thread Participants: 1