mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Make click and doubleclick events work on View.
This commit is contained in:
parent
3276616f53
commit
d92628a432
1 changed files with 9 additions and 10 deletions
|
@ -1254,20 +1254,19 @@ new function() { // Injection scope for event handling on the browser
|
||||||
// See if we're clicking again on the same item, within the
|
// See if we're clicking again on the same item, within the
|
||||||
// double-click time. Firefox uses 300ms as the max time
|
// double-click time. Firefox uses 300ms as the max time
|
||||||
// difference:
|
// difference:
|
||||||
if (item) {
|
|
||||||
dblClick = item === clickItem
|
dblClick = item === clickItem
|
||||||
&& (Date.now() - clickTime < 300);
|
&& (Date.now() - clickTime < 300);
|
||||||
downItem = clickItem = item;
|
downItem = clickItem = item;
|
||||||
// Only start dragging if the mousedown event has not
|
// Only start dragging if the mousedown event has not
|
||||||
// stopped propagation.
|
// stopped propagation.
|
||||||
dragItem = !stopped && item;
|
dragItem = !stopped && item;
|
||||||
}
|
|
||||||
downPoint = lastPoint = point;
|
downPoint = lastPoint = point;
|
||||||
} else if (mouse.up) {
|
} else if (mouse.up) {
|
||||||
// Emulate click / doubleclick, but only on item, not view
|
// Emulate click / doubleclick, but only on item, not view
|
||||||
if (!stopped && item && item === downItem) {
|
if (!stopped && item === downItem) {
|
||||||
clickTime = Date.now();
|
clickTime = Date.now();
|
||||||
emitMouseEvent(item, dblClick ? 'doubleclick' : 'click',
|
emitMouseEvents(this, item,
|
||||||
|
dblClick ? 'doubleclick' : 'click',
|
||||||
event, point, downPoint);
|
event, point, downPoint);
|
||||||
dblClick = false;
|
dblClick = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue