1. #1
    Sencha User tf.alves's Avatar
    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    54
    Vote Rating
    0
    Answers
    3
    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
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    Answers
    3106
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      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
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost 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
    Vote Rating
    0
    Answers
    3
    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