-
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?
-
The direction should still be accessible in the itemswipe event on the event object argument.
-
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
-
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);
}
}
});
-
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);
}
-
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' }
]
}
});
}
});