Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5311] iOS: Scrollable View currentPage Doesn't Change When Scrolling 50%, Despite Comments in Code

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T14:23:36.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sSprint 2011-44, Release 1.8.0
ComponentsiOS
Labelsmodule_scrollableview, qe-testadded
ReporterDawson Toth
AssigneeDawson Toth
Created2011-09-20T08:08:49.000+0000
Updated2014-06-19T12:46:25.000+0000

Description

Problem

The currentPage of a scrollable view does not always sync up with the visible dot. This happens because the dot is updated when the user scrolls over 50%, and the currentPage only updates when the underlying scroll view ends decelerating. This is a problem because the app may act based on the currentPage of the scrollable view. So if the user swipes, and then hits a button that shows different content based on the currentPage, the wrong content can show up.

Reproduction

Drop the following in an app.js, and swipe right and left to the various pages of the scrollable view. Down at the bottom, I have placed a label that is updated with the currentPage.
var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});

var scroll = Ti.UI.createScrollableView({
    bottom: 30,
    views: [
        Ti.UI.createView({ backgroundColor: 'cyan' }),
        Ti.UI.createView({ backgroundColor: 'magenta' }),
        Ti.UI.createView({ backgroundColor: 'yellow' })
    ],
    pagingControlColor: '#000',
    pagingControlHeight: 30
});
win.add(scroll);

var currentPageLabel = Ti.UI.createLabel({
    text: 'Current Page: Loading...', textAlign: 'center',
    bottom: 0, right: 0, left: 0,
    height: 30,
    color: '#fff', backgroundColor: '#000'
});
win.add(currentPageLabel);
setInterval(function() {
    currentPageLabel.text = 'Current Page: ' + scroll.currentPage;
}, 50);

win.open();

Comments

  1. Dawson Toth 2011-09-20

    Pull request opened: https://github.com/appcelerator/titanium_mobile/pull/478 Note that this should also get merged in to branch-5062
  2. Dustin Hyde 2011-12-09

    Bug fixed. Verified on: SDK: 1.8.0.1.v20111209102124 Studio: 1.0.7.201112080131 OS: OS X Lion Devices Tested: iPhone Simulator 5.0, iPhone 5.0.1
  3. Wilson Luu 2012-01-04

    Reopening bug to add tag
  4. Wilson Luu 2012-01-04

    Added tag

JSON Source