mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 13:32:28 -05:00
Merge pull request #1464 from cwillisf/fix-fill-tool-touch
Fix fill tool for touch: update hover on mouse up
This commit is contained in:
commit
2a9fb2356d
1 changed files with 11 additions and 1 deletions
|
@ -21,6 +21,7 @@ class FillTool extends paper.Tool {
|
|||
|
||||
// We have to set these functions instead of just declaring them because
|
||||
// paper.js tools hook up the listeners in the setter functions.
|
||||
this.onMouseDown = this.handleMouseDown;
|
||||
this.onMouseMove = this.handleMouseMove;
|
||||
this.onMouseUp = this.handleMouseUp;
|
||||
|
||||
|
@ -91,7 +92,7 @@ class FillTool extends paper.Tool {
|
|||
setPrevHoveredItemId (prevHoveredItemId) {
|
||||
this.prevHoveredItemId = prevHoveredItemId;
|
||||
}
|
||||
handleMouseMove (event) {
|
||||
updateFillPreview (event) {
|
||||
const hoveredItem = getHoveredItem(event, this.getHitOptions(), true /* subselect */);
|
||||
if ((!hoveredItem && this.prevHoveredItemId) || // There is no longer a hovered item
|
||||
(hoveredItem && !this.prevHoveredItemId) || // There is now a hovered item
|
||||
|
@ -152,6 +153,15 @@ class FillTool extends paper.Tool {
|
|||
this._setFillItemColor(this.fillColor, this.fillColor2, this.gradientType, event.point);
|
||||
}
|
||||
}
|
||||
handleMouseDown (event) {
|
||||
// on touch, the user might touch-and-hold to preview what the fill tool would do
|
||||
// if they don't move their finger at all after the "mouse down" event
|
||||
// then this might be our only chance to give them a good preview
|
||||
this.updateFillPreview(event);
|
||||
}
|
||||
handleMouseMove (event) {
|
||||
this.updateFillPreview(event);
|
||||
}
|
||||
handleMouseUp (event) {
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
if (this.fillItem) {
|
||||
|
|
Loading…
Reference in a new issue