I have some div
in my page that when an user drags one of them to left, the div
would fade out.
My question is:
How can I be able to detect when the users drags to the left or to the right direction?
I have some div
in my page that when an user drags one of them to left, the div
would fade out.
My question is:
How can I be able to detect when the users drags to the left or to the right direction?
You must add this inside droppable
init, inside drop
param function.
I dont know sencha-touch, but his logic looks really, really ugly.
if($(ui.helper).hasClass('ui-draggable')){
//draggable item
if(ui.position.left < 0){
alert('Draggable dragged to left');
}
else if(ui.position.left > 0){
alert('Draggable dragged to right');
}
if(ui.position.top < 0){
alert('Draggable dragged to top');
}
else if(ui.position.top > 0){
alert('Draggable dragged to bottom');
}
}
else{
//sortable item
var originalPosition = ui.helper.data().sortableItem.originalPosition;
if(ui.position.left < originalPosition.left){
alert('Draggable dragged to left');
}
else if(ui.position.left > originalPosition.left){
alert('Draggable dragged to right');
}
if(ui.position.top < originalPosition.top){
alert('Draggable dragged to top');
}
else if(ui.position.top > originalPosition.top){
alert('Draggable dragged to bottom');
}
}