import com.google.gwt.query.client.GQuery;\r
import com.google.gwt.query.client.plugins.events.GqEvent;\r
import com.google.gwt.user.client.Event;\r
+import com.google.gwt.user.client.ui.Label;\r
+import com.google.gwt.user.client.ui.RootPanel;\r
\r
/**\r
* Base class for all plug-in that need to handle some mouse interactions.\r
private MouseOptions options;\r
private boolean preventClickEvent = false;\r
private boolean touchSupported = false;\r
+ private int startX = -1;\r
+ private int startY = -1;\r
\r
protected MousePlugin(GQuery gq) {\r
super(gq);\r
* \r
*/\r
protected boolean mouseMove(Element element, GqEvent event) {\r
+\r
if (started) {\r
event.getOriginalEvent().preventDefault();\r
return mouseDrag(element, event);\r
* \r
*/\r
protected boolean mouseUp(Element element, GqEvent event) {\r
+\r
unbindOtherEvents();\r
if (started) {\r
started = false;\r
preventClickEvent = (event.getCurrentEventTarget() == startEvent.getCurrentEventTarget());\r
mouseStop(element, event);\r
}\r
+\r
return true;\r
\r
}\r
\r
private boolean distanceConditionMet(GqEvent event) {\r
int neededDistance = options.getDistance();\r
- int startX = getClientX(startEvent);\r
- int startY = getClientY(startEvent);\r
int xDistance = Math.abs(startX - getClientX(event));\r
int yDistance = Math.abs(startY - getClientY(event));\r
// in jQuery-ui we take the greater distance between x and y... not really\r
// good !\r
// int mouseDistance = Math.max(xMouseDistance, yMouseDistance);\r
// use Pythagor theorem !!\r
+ \r
int mouseDistance = (int) Math.sqrt(xDistance * xDistance + yDistance * yDistance);\r
return mouseDistance >= neededDistance;\r
}\r
\r
private void reset(GqEvent nativeEvent) {\r
this.startEvent = nativeEvent;\r
+ this.startX = getClientX(nativeEvent);\r
+ this.startY = getClientY(nativeEvent);\r
this.mouseUpDuration = new Duration();\r
}\r
\r