Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17561] Android: Fixed - When adding swipe event to a tabGroup, th... #6538

Closed
wants to merge 1 commit into from

Conversation

ashcoding
Copy link
Contributor

...e inside tableview's inside won't scroll nice (parity issue)

Jira: https://jira.appcelerator.org/browse/TIMOB-17561

In the SimpleOnGestureListener, if onFling returns True, it takes it as that the event is over and will stop the flinging action of the view as the event is consumed. To allow it to continue to scroll with inertia, it needs to always return false.

// create table view 1
var win1 = Ti.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#000'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

var rows1 = [];
for(var i = 0; i < 50; i++) {
    rows1.push({ title: 'Row 1:' + i});
}

var table1 = Titanium.UI.createTableView({
    data: rows1,
    width: 'auto',
    height: 'auto'
});

win1.add(table1);

// create table view 2
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#000'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var rows2 = [];
for(var i = 0; i < 50; i++) {
    rows2.push({ title: 'Row 2:' + i});
}

var table2 = Titanium.UI.createTableView({
    data: rows2,
    width: 'auto',
    height: 'auto'
});

win2.add(table2);

//  create tabgroup and tabs
var tabGroup = Ti.UI.createTabGroup();
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  

// Event handler to change tab on left/right swipe
// This is where the problem comes in.
// Comment out the 'swipe' listener and normal table view scroll behavior will be back

tabGroup.addEventListener('swipe', function(e) {
    var activeTabIndex = tabGroup.tabs.indexOf(tabGroup.activeTab);

    if(e.direction === 'right' && activeTabIndex > 0) {
        tabGroup.setActiveTab(activeTabIndex - 1);
    } else if(e.direction === 'left' && activeTabIndex < tabGroup.tabs.length - 1) {
        tabGroup.setActiveTab(activeTabIndex + 1);
    }
    // Is there something missing in this event handler to have native behavior when the swipe
    // direction is not left or right?
});

// open tab group
tabGroup.open();

… the inside tableview's inside won't scroll nice (parity issue)
@hieupham007
Copy link
Contributor

This change affects all apps, not just apps with tableview, which will cause behavioral changes to apps that expect the event to be eaten. I would advise not to merge this to master unless we are planning to redefine Android gesture architecture.

@ingo
Copy link
Contributor

ingo commented Jan 7, 2015

I agree. I would not want to change this behavior without careful consideration.

@ashcoding
Copy link
Contributor Author

Okay. Understood. Shall I close this PR?

@ingo
Copy link
Contributor

ingo commented Jan 7, 2015

If you can fix it without this behavior change, is that a small change to this PR, or a new approach?

@ashcoding
Copy link
Contributor Author

Probably a whole new approach. Thus, I think this PR can be rejected.

@hieupham007
Copy link
Contributor

Closing PR

@hieupham007 hieupham007 closed this Jan 7, 2015
@ashcoding ashcoding deleted the TIMOB-17561 branch May 21, 2015 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants