Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13698] Android: Adding a 'swipe' event on a window that has a scrollView attached to it, the scrollView does not bounce back or highlighted blue part remains when pulling the scroll beyond the end

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2013-07-25T22:24:49.000+0000
Affected Version/sRelease 3.0.2, Release 3.1.0
Fix Version/s2013 Sprint 15 API, 2013 Sprint 15
ComponentsAndroid
LabelssupportTeam
ReporterRupesh Sharma
AssigneeShameer Jan
Created2013-04-29T09:33:54.000+0000
Updated2017-03-29T17:49:18.000+0000

Description

Description

Adding a 'swipe' event on a window that has a scrollView attached to it, the scrollView does not retract to the original position when pulling the scroll beyond the end. On pulling the scroll beyond the end you will see the blue highlighted part doesnt go back or bounce back as it should. Comment out the swipe event handler to see what is supposed to look like in the below provided code.

Test Code

var w = Ti.UI.createWindow({
     backgroundColor : '#cecece',
     title : 'added by click from label1'
 });

 w.addEventListener('swipe', function(e){

 });

 var container = Ti.UI.createView({
     width : Ti.UI.FILL, height : Ti.UI.FILL, right : 0, left : 0
 })
 w.add(container)

 var scroll = Ti.UI.createScrollView({
     top : 0,
     backgroundColor : '#E9E9E9'
 })
 container.add(scroll);

 var inner = Ti.UI.createView({
    borderRadius : 0,
    top : 0,
    layout : 'vertical',
    height : Ti.UI.SIZE,
    width : Ti.UI.FILL,
    bottom : 5
});
scroll.add(inner);

for(var i = 0; i < 100; i++){
    inner.add(Titanium.UI.createLabel({ color:'#999', text:'I am Window 2 label ' + i, font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }));
}
 w.open();
Note: On commenting the swipe event listener it work fine.

Attachments

FileDateSize
WP_20130607_001.mp42013-06-07T10:32:37.000+00006471404

Comments

  1. Shameer Jan 2013-05-30

    The issue cannot reproduce with master 3.2.0 Tested on: Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.2.0 Device: Samsung galaxy s duos Android version: 4.0.4
  2. Hieu Pham 2013-07-25

    When you have 'swipe' event in a scrollable view, the gesture event will be eaten when 'swipe' is fired, which causes the view to stop scrolling (in this case visual glitches - which is dependent on phone implementation). A simple workaround would be to utilize 'touchstart' and 'touchend' events to determine a swipe manually. For instance, this snippet would work for horizontal swipe:
       var startX = -1;
        w.addEventListener('touchstart', function(e) {
           startX = e.x;
        });
        w.addEventListener('touchend', function(e) {
           //if difference exceeds threshold (in this case 30 pixels), it's a swipe.
           if (startX > 0 && e.x - startX > 30) {
             Ti.API.info("horizontal swipe!");
           }
           startX = -1;
        });
       
  3. Ingo Muschenetz 2013-07-25

    My understanding is that this is a non-native Android behavior, so we do not wish to add it to the core SDK. However, for those interested in implementing the functionality regardless, please see the workaround provided by [~hpham]
  4. Guto Dasilva 2013-07-26

    The android version tested is not the same that this problem manifests. The android version that this happens is 2.3.6. I was on a call with you guys via skype to help reproduce the problem and we were able to reproduced and titanium team i was working with understood the problem.
  5. Ingo Muschenetz 2013-07-26

    [~mobile_developer@onforce.com] I realize now that [~hpham]'s workaround was hidden to normal users. You should be able to view it now.
  6. Guto Dasilva 2013-07-26

    [~ingo] I still cant see it.
  7. Guto Dasilva 2013-07-26

    [~ingo] my workaround is not to add the swipe event on models 2.3.6 which is not ideal since we have an action menu style that swipes to the side. So I am curious what [~hpham] workaround is. Thanks
  8. Hieu Pham 2013-07-26

    You should be able to see the workaround now - basically manipulating 'touchstart' and 'touchend' events.
  9. Guto Dasilva 2013-07-29

    ok [~hpham] will try that. Thanks
  10. Lee Morris 2017-03-29

    Closing ticket with reference to the above comments.

JSON Source