1. #1
    Sencha User tf.alves's Avatar
    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    54
    Answers
    3
    Vote Rating
    0
    tf.alves is on a distinguished road

      0  

    Default Unanswered: Scrolling to list item problem(s)!

    Unanswered: Scrolling to list item problem(s)!


    Hi again,

    I am (still) trying to get my scroller to scroll to the selected target on itemTap event.

    I'm doing this:

    Code:
    onListItemTap: function(dataview, index, target, record, e, options) {
            var scroller = dataview.getScrollable().getScroller();
            var offsets = target.getOffsetsTo(scroller);
            scroller.scrollTo(0,target[1],true);
    }
    But I always get:
    Code:
    Cannot read property 'x' of null
    I don't get what I'm doing wrong. I managed to get it working by passing the target.dom.offsetTop, but I don't feel that this is the right way of doing this.

    Also, how do I get the scrollTo to animate properly, I think I have to pass an animation object to it, but I just don't know how to create this animation object.

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,142
    Answers
    3504
    Vote Rating
    855
    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


    scrollTo takes 3 arguments, the x, y and animation.

    Does target[1] equal the y value you want to scroll to?
    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 tf.alves's Avatar
    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    54
    Answers
    3
    Vote Rating
    0
    tf.alves is on a distinguished road

      0  

    Default


    It was my mistake when I copied the code here, it should read offsets[1] instead of target[1]. But the problem isn't in the scrollTo, as I said, I found a (dirty) workaround which works perfectly, but I wanted to do this the right way. The problem is in the getOffsetsTo, which always returns me that error no matter what component I send to it...

    About the animation part, I tried:

    Code:
    new Ext.Anim({    duration:1000
    })
    but still got no results...

    Please help

Thread Participants: 1