Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

scrollTo in scrollView doesn't work !?!?

Here is my code:

var scrollView = Titanium.UI.createScrollView({
            contentHeight: 600,
            top:0,
            showVerticalScrollIndicator:true
        });

scrollView.scrollTo(0, 100);

but nothing happens. Is it a bug?

— asked October 11th 2010 by Den Cambodia
  • bug
  • scrollto
  • scrollview
0 Comments

2 Answers

  • I had an issue where I wanted the view to scroll when the window loads, but there is no onload event for windows. So I did a setInterval:

    var offset = 0;
    scrollView.addEventListener('scroll', function(e) {
        if (e.y!=null) {
            offset = e.y;
            Ti.API.info('offset: '+offset);
        } else {
            Ti.API.info('offset: null.. no idea why');
        }
    });
    
    var init = setInterval(function(e){
        Ti.API.info('check if '+offset+' = 50');
        if (offset==50) {
            Ti.API.info('we are done');
            clearInterval(init);
        }
        scrollView.scrollTo(0,50);
    },100);
    

    See my answer here.

    — answered April 5th 2011 by Joe iEntry
    permalink
    0 Comments
  • A ScrollView has to contain another view which is larger than the ScrollView itself. When this happens, the ScrollView can be made to move the view(s) it contains around. In your example, you have a ScrollView and nothing else so there is nothing to scroll. If you look at the Kitchen Sink scroll_view_basics.js you'll see some good examples of how a ScrollView is used. And no, there is no bug I am aware of at this time.

    http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.ScrollView-object

    — answered October 11th 2010 by John McKnight
    permalink
    1 Comment
    • good now it's working thx u

      — commented October 11th 2010 by Den Cambodia
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.