1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    39
    Vote Rating
    0
    ashapiro75 is on a distinguished road

      0  

    Default Detect Swipe on Screen

    Detect Swipe on Screen


    Ok, I've been combing through the forums and I've come across a few different ways of adding listeners and I've tried them but none seem to do what I want.

    I want to detect a swipe on the screen. So the listener would be on the main viewport or application itself.. I don't know the best place to put it. Say my app is just an empty container and I want to detect a swipe on it.

    I've tried adding the listener in the controller init function and it didn't seem to work. It didn't throw an error but nothing happened.

    I've seen posts that said custom events can't be handled with architect right now but then I've seen other posts that I thought may contradict that.

    Basically I want to be able to swipe up or down on something like a container.

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    350
    Vote Rating
    1
    bharatn is on a distinguished road

      0  

    Default


    In your container initialize event, add listener on the container element

    Code:
    component.element.on('swipe', function () {
        alert('swipe');    
    });
    Bharat Nagwani
    Sencha Designer Development Team

  3. #3
    Sencha User
    Join Date
    Oct 2010
    Posts
    39
    Vote Rating
    0
    ashapiro75 is on a distinguished road

      0  

    Default


    Bah, that works perfect, thanks!

    Another quick question about this if I may, it seems as though the swipe only gets detected if it's a left or right swipe. Is there no vertical swipe event?

    Not a big deal now that you have pointed me in the right direction, I can use touchdrag and grab the x / y co-ordinates if there isn't a vertical swipe event.

  4. #4
    Sencha User
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    89
    Vote Rating
    7
    Greg Arnott is on a distinguished road

      0  

    Default


    Vertical swipe is turned off by default, for performance reasons.

    Can be turned back on using:
    Code:
    Ext.application({
     
        eventPublishers: {
            touchGesture: {
                recognizers: {
                    swipe: {
                        //this will include both vertical and horizontal swipe recognisers
                        xclass: 'Ext.event.recognizer.Swipe'
                    }
                }
            }
        },
        name: 'AppName',
        launch: function() {
             Ext.create('AppName.view.Container', {fullscreen: true});
     
        }
     
    });

Thread Participants: 2