PDA

View Full Version : Positioning of Drag and Drop elments



Andre008
25 Jul 2011, 4:47 AM
Hello,

i make my first steps with sencha touch and now im try to give Draggable explicit positions on screen.

The initiation looks like this:



this.test= new Ext.util.Draggable('test', {

revert: true

});
this.test.el.setX(250);
this.test.el.setY(130);



The Listener in Droppable element look like this:



this.droppable = new Ext.util.Droppable('droppable', {


listeners: {

// dropdeactivate gute lösung

dropdeactivate : function(droppable, draggable, e) {


var pos_drag_X = draggable.el.getX();
var pos_drag_Y = draggable.el.getY();
var pos_drop_X = droppable.el.getX();
var pos_drop_Y = droppable.el.getY();





if(draggable.el.id == "test"){


if(((pos_drag_X >=pos_drop_X-40) && (pos_drag_X <=pos_drop_X+40) ) &&
((pos_drag_Y >= pos_drop_Y-25) && (pos_drag_Y <= pos_drop_Y+25)) )
{

//droppable.disable();

store.add({'firstName':"liegend "});

//droppable.enable();


c

draggable.el.setY(0);


}



My problem is, that i can drag and drop the element two times and than it runs out of screen. I think that the draggable.el.setX(0) and draggable.el.setY(0) increment the value of x and y.
But i need a fix position on screen.
Have anyone a solution for this problem?

Thanks Andre

Andre008
25 Jul 2011, 5:47 AM
Hi,

i think, instead of


this.test.el.setX(250);
this.test.el.sety(250);


its better to use for example:


this.test.moveTo(250, 250)

for draggable elements, so they dont run out of screen.