mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
In case of doubleclick mouse events, still fire normal clicks if no doubleclick handler stops event bubbling.
This commit is contained in:
parent
2955b12dd7
commit
701c5fd9e7
1 changed files with 11 additions and 8 deletions
|
@ -74,10 +74,11 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
doubleClick,
|
||||
clickTime;
|
||||
|
||||
// Returns false if event was stopped, true otherwise, wether handler was
|
||||
// called or not!
|
||||
function callEvent(type, event, point, target, lastPoint, bubble) {
|
||||
var item = target,
|
||||
mouseEvent,
|
||||
called = false;
|
||||
mouseEvent;
|
||||
while (item) {
|
||||
if (item.responds(type)) {
|
||||
// Create an reuse the event object if we're bubbling
|
||||
|
@ -85,13 +86,13 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
mouseEvent = new MouseEvent(type, event, point, target,
|
||||
// Calculate delta if lastPoint was passed
|
||||
lastPoint ? point.subtract(lastPoint) : null);
|
||||
called = item.fire(type, mouseEvent) || called;
|
||||
if (called && (!bubble || mouseEvent._stopped))
|
||||
break;
|
||||
if (item.fire(type, mouseEvent)
|
||||
&& (!bubble || mouseEvent._stopped))
|
||||
return false;
|
||||
}
|
||||
item = item.getParent();
|
||||
}
|
||||
return called;
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleEvent(view, type, event, point, lastPoint) {
|
||||
|
@ -144,8 +145,10 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
}
|
||||
if (item == downItem) {
|
||||
clickTime = Date.now();
|
||||
callEvent(doubleClick ? 'doubleclick' : 'click', event,
|
||||
downPoint, overItem);
|
||||
if (!doubleClick
|
||||
// callEvent returns false if event is stopped.
|
||||
|| callEvent('doubleclick', event, downPoint, overItem))
|
||||
callEvent('click', event, downPoint, overItem);
|
||||
doubleClick = false;
|
||||
}
|
||||
downItem = null;
|
||||
|
|
Loading…
Reference in a new issue