PDA

View Full Version : Preventing card switch using swipe gesture on a specific component



jep
30 Nov 2010, 8:44 AM
I'm wondering if it's possible to disable card swiping in a specific area, say a panel child inside a card. Swiping on the area of the card outside the panel left/right would switch cards on the carousel as normal, but swiping inside the panel would not.

Here's an example carousel that I'd like to add the behavior to:



<html>
<head>
<title>test</title>
<link rel="stylesheet" href="sencha/resources/css/sencha-touch-debug.css" type="text/css">
<script type="text/javascript" src="sencha/sencha-touch.js"></script>

<script type="text/javascript">

Ext.setup({
onReady: function() {

var noSwipePanel = new Ext.Panel({
html:"Can't swipe here!",
style:{backgroundColor:'#C0C0C0', style:{border:'1px solid black'}}
});

var mainPanel = new Ext.Carousel({
layout:'fit',
fullscreen:true,
items:[
{
xtype:'panel',
style:{backgroundColor:'#FFC0C0'},
layout:'vbox',
defaults:{height:200, width:'100%'},
items:[
{xtype:'panel', html:'Can swipe here.'},
noSwipePanel,
{xtype:'panel', html:'Can swipe here.'}
]
},
{xtype:'panel', html:'Panel 2', style:{backgroundColor:'#C0FFC0'}}
],
});
}
});

</script>
</head>

<body></body>
</html>


Thanks!

jep
9 Dec 2010, 11:37 AM
So... impossible?

VinylFox
9 Dec 2010, 11:55 AM
you could add your own swipe event and cancel the bubbling using the stopEvent method.

http://dev.sencha.com/deploy/touch/docs/?class=Ext.EventObject

Have not tried it, just a guess.

interfasys
25 Jun 2011, 9:54 PM
...
listeners: {
scope:this,
element: 'el',
drag: this.killBubbling
}
...

killBubbling: function(event) {
console.log('Killed carousel!');
event.stopEvent();
}

jep
25 Jun 2011, 9:55 PM
Thanks for the reply. Though by this point the code is so different that carousel doesn't even exist. :D

interfasys
25 Jun 2011, 10:02 PM
Hehe... :) I figured, but then that's one of the thread that comes up when you're looking for a solution, so since I found it, I thought I'd share :)

jep
25 Jun 2011, 10:04 PM
I completely understand! I've answered several ancient questions simply because I figured if they came up when I was looking for a certain topic, they'd come up for other folks. Nice to see there are others who do this. :)

One of the worst things is finding a thread from a year back that's asking exactly the same question as the one you're asking, and it never got any answer.