PDA

View Full Version : Window Snappimg when dragged and dropped



swarnendude
30 Jun 2010, 3:21 AM
Hi,

I was trying to find out a way such that when a window is dragged and dropped, the final position should be latest integer divisible by 10. For example :

It it is moved at LEFT at x = 136, y = 43,
then the final position should be x = 130, y = 40

If moved at RIGHT,
then the final position should be x = 140, y = 50

I was trying to implement it by extending Ext.Window.DD class and overriding endDrag(e) method but did not get a solution.

Any help?

Animal
30 Jun 2010, 3:31 AM
myWindow.dd.xTickSize = myWindow.dd.yTickSize = 10;

swarnendude
30 Jun 2010, 3:49 AM
Animal, thanks for reply.


myWindow.dd.xTickSize = myWindow.dd.yTickSize = 10;

Did this but could not see any effect. Both the parameters set properly when checked in console but no effect.
What is Tick Interval?

Animal
30 Jun 2010, 4:05 AM
Try making the tickSizes 50. You'll see it then.

swarnendude
30 Jun 2010, 4:08 AM
No.. I tried with tickSizes 100 even. Lemme show you the code:


var win = new Ext.Window({
id : id,
title : 'Window',
width : 200,
height : 100,
renderTo : 'center_pan',
manager : this.windows
});

win.dd.xTickSize = win.dd.yTickSize = 100;

win.show();

Animal
30 Jun 2010, 4:10 AM
Yeah, and you didn't see any errors at all did you?

swarnendude
30 Jun 2010, 4:10 AM
Yes...no error!

Animal
30 Jun 2010, 4:15 AM
OK....

I found that you need constrain: true to make it do snapping

swarnendude
30 Jun 2010, 4:27 AM
Ok...now its working. I didn't know there is already a feature like this.
Thanks Animal.