Hybrid View

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    245
    Vote Rating
    4
    Answers
    3
    Kurt001 is on a distinguished road

      0  

    Default Unanswered: itemswipe direction

    Unanswered: itemswipe direction


    Hi,

    I saw that the swipe listener returns the direction of the swipe.
    Now I am looking for the direction on the itemSwipe listener for the DataView.

    Is there a better way to get the direction than to catch the itemTouchStart and item TouchEnd event.

    Can I read the starting x - value from the itemSwipe?

    Any idea?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,581
    Vote Rating
    433
    Answers
    3100
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    The direction should still be accessible in the itemswipe event on the event object argument.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    245
    Vote Rating
    4
    Answers
    3
    Kurt001 is on a distinguished road

      0  

    Default


    This is the itemswipe event
    Which one would show the diretion?
    Code:
    event
    MouseEvent
    
    
    • altKey: false
    • bubbles: true
    • button: 0
    • cancelBubble: false
    • cancelable: true
    • changedTouches: Array[1]
    • charCode: 0
    • clientX: 300
    • clientY: 204
    • clipboardData: undefined
    • ctrlKey: false
    • currentTarget: #document
    • dataTransfer: null
    • defaultPrevented: false
    • detail: 1
    • eventPhase: 3
    • fromElement: null
    • identifier: 1
    • keyCode: 0
    • layerX: 300
    • layerY: -29
    • metaKey: false
    • offsetX: 258
    • offsetY: 49
    • pageX: 300
    • pageY: 204
    • relatedTarget: null
    • returnValue: true
    • screenX: -1227
    • screenY: 432
    • shiftKey: false
    • srcElement: <div>
    • target: <div>
    • targetTouches: Array[0]
    • timeStamp: 1352742968502
    • toElement: <div>
    • touches: Array[0]
    • type: "mouseup"
    • view: Window
    • webkitMovementX: 0
    • webkitMovementY: 0
    • which: 1
    • x: 300
    • y: 204

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,581
    Vote Rating
    433
    Answers
    3100
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Something like this:

    Code:
    Ext.Viewport.add({
        xtype   : 'list',
        itemTpl : '{test}',
        store   : {
            fields : ['test'],
            data   : [
                { test : 'foo' }
            ]
        },
        listeners : {
            itemswipe : function(list, index, item, record, event) {
                console.log(event.direction);
            }
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    245
    Vote Rating
    4
    Answers
    3
    Kurt001 is on a distinguished road

      0  

    Default


    Interesting. But ....

    It works what you are doing - inline:
    Code:
    listeners : {
             itemswipe : function(list, index, item, record, event) {
                     console.log(event.direction);
             }
     }
    but it does not like this. What am I doing wrong?
    Code:
            listeners : {
                // Item-Swipe
                itemswipe : 'onItemSwipe'
            }
    
        },
    
        onItemSwipe: function(list, index, item, record, event) {
            console.log(event.direction);
        }

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,581
    Vote Rating
    433
    Answers
    3100
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Still works for me:

    Code:
    Ext.define('MyList', {
        extend : 'Ext.dataview.List',
        xtype  : 'mylist',
    
        config : {
            itemTpl   : '{test}',
            listeners : {
                itemswipe : 'onMyItemSwipe'
            }
        },
    
        onMyItemSwipe : function(list, index, item, record, event) {
            console.log(event.direction);
        }
    });
    
    Ext.application({
        name   : 'Test',
    
        launch : function () {
    
            Ext.Viewport.add({
                xtype : 'mylist',
                store : {
                    fields : ['test'],
                    data   : [
                        { test : 'foo' }
                    ]
                }
            });
    
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.