Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-9474

Android: ScrollableView throws exception when using scrollToView()

    Details

      Description

      Trying to use scrollToView() on a ScrollableView sometimes results in an exception being thrown.
      This appears to be triggered by creating the ScrollableView and passing a "currentPage" parameter.

      This regression appears in the KS Base UI > Views > Scroll Views > Scrollable View.
      Try scrolling to the next view by using the arrows on the bottom (these call scrollToView()).

      Standalone test case

      var win = Ti.UI.createWindow({layout: 'vertical'});
       
      var views = ['blue', 'red', 'yellow'].map(function(color) {
      	return Ti.UI.createView({backgroundColor: color});
      });
       
      var scrollable = Ti.UI.createScrollableView({
      	height: '80%',
      	currentPage: 1,
      	views: views
      });
      win.add(scrollable);
       
      var controls = Ti.UI.createView({
      	height: '20%'
      });
      win.add(controls);
       
      var currentView = 1;
       
      var prevButton = Ti.UI.createButton({
      	title: "Prev",
      	left: 10,
      	width: 200
      });
      controls.add(prevButton);
      prevButton.addEventListener('click', function() {
      	if (currentView === 0) return;
      	scrollable.scrollToView(--currentView);
      });
       
      var nextButton = Ti.UI.createButton({
      	title: "Next",
      	right: 10,
      	width: 200
      });
      controls.add(nextButton);
      nextButton.addEventListener('click', function() {
      	if (currentView == (scrollable.views.length - 1)) return;
      	var view = scrollable.views[++currentView];
      	scrollable.scrollToView(view);
      });
       
      scrollable.addEventListener('scroll', function(e) {
      	currentView = e.currentPage;
      });
       
      win.open();
      

      Run the test case and try switching views by using the "next" or "prev" buttons.

      Expected: Views change without any crash.

        Attachments

          Activity

            People

            • Assignee:
              joshroesslein Josh Roesslein
              Reporter:
              joshroesslein Josh Roesslein
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-13637
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration