Always stop events when they are handled by our View, removing the need to specifically handle touch events on iOS.

This commit is contained in:
Jürg Lehni 2011-06-22 08:09:22 +01:00
parent c2244be53b
commit b3e1fa68b8

View file

@ -369,21 +369,20 @@ var View = this.View = Base.extend({
var view = View.focused; var view = View.focused;
if (!view || !(tool = view._scope.tool)) if (!view || !(tool = view._scope.tool))
return; return;
// If the event was triggered by a touch screen device, prevent the
// default behaviour, as it will otherwise scroll the page:
if (event && event.targetTouches)
DomEvent.preventDefault(event);
var point = event && viewToArtwork(view, event); var point = event && viewToArtwork(view, event);
var onlyMove = !!(!tool.onMouseDrag && tool.onMouseMove); var onlyMove = !!(!tool.onMouseDrag && tool.onMouseMove);
if (dragging && !onlyMove) { if (dragging && !onlyMove) {
curPoint = point || curPoint; curPoint = point || curPoint;
if (curPoint && tool.onHandleEvent('mousedrag', curPoint, event)) if (curPoint && tool.onHandleEvent('mousedrag', curPoint, event)) {
view.draw(true); view.draw(true);
DomEvent.stop(event);
}
// PORT: If there is only an onMouseMove handler, also call it when // PORT: If there is only an onMouseMove handler, also call it when
// the user is dragging: // the user is dragging:
} else if ((!dragging || onlyMove) } else if ((!dragging || onlyMove)
&& tool.onHandleEvent('mousemove', point, event)) { && tool.onHandleEvent('mousemove', point, event)) {
view.draw(true); view.draw(true);
DomEvent.stop(event);
} }
} }
@ -396,8 +395,10 @@ var View = this.View = Base.extend({
if (tool) { if (tool) {
if (timer != null) if (timer != null)
timer = clearInterval(timer); timer = clearInterval(timer);
if (tool.onHandleEvent('mouseup', viewToArtwork(view, event), event)) if (tool.onHandleEvent('mouseup', viewToArtwork(view, event), event)) {
view.draw(true); view.draw(true);
DomEvent.stop(event);
}
} }
} }