mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
move hit options declaration into function
This commit is contained in:
parent
adbd023551
commit
3bb606e16a
1 changed files with 33 additions and 40 deletions
|
@ -32,43 +32,6 @@ class ReshapeTool extends paper.Tool {
|
|||
this.clearHoveredItem = clearHoveredItem;
|
||||
this.onUpdateSvg = onUpdateSvg;
|
||||
this.prevHoveredItem = null;
|
||||
this._hitOptionsSelected = {
|
||||
match: function (item) {
|
||||
if (!item.item || !item.item.selected) return;
|
||||
if (item.type === 'handle-out' || item.type === 'handle-in') {
|
||||
// Only hit test against handles that are visible, that is,
|
||||
// their segment is selected
|
||||
if (!item.segment.selected) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
segments: true,
|
||||
stroke: true,
|
||||
curves: true,
|
||||
handles: true,
|
||||
fill: true,
|
||||
guide: false
|
||||
};
|
||||
this._hitOptions = {
|
||||
match: function (item) {
|
||||
if (item.type === 'handle-out' || item.type === 'handle-in') {
|
||||
// Only hit test against handles that are visible, that is,
|
||||
// their segment is selected
|
||||
if (!item.segment.selected) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
segments: true,
|
||||
stroke: true,
|
||||
curves: true,
|
||||
handles: true,
|
||||
fill: true,
|
||||
guide: false
|
||||
};
|
||||
this.lastEvent = null;
|
||||
this.mode = ReshapeModes.SELECTION_BOX;
|
||||
this.selectionRect = null;
|
||||
|
@ -89,9 +52,39 @@ class ReshapeTool extends paper.Tool {
|
|||
paper.settings.handleSize = 8;
|
||||
}
|
||||
getHitOptions (preselectedOnly) {
|
||||
this._hitOptions.tolerance = ReshapeTool.TOLERANCE / paper.view.zoom;
|
||||
this._hitOptionsSelected.tolerance = ReshapeTool.TOLERANCE / paper.view.zoom;
|
||||
return preselectedOnly ? this._hitOptionsSelected : this._hitOptions;
|
||||
const hitOptions = {
|
||||
segments: true,
|
||||
stroke: true,
|
||||
curves: true,
|
||||
handles: true,
|
||||
fill: true,
|
||||
guide: false
|
||||
};
|
||||
if (preselectedOnly) {
|
||||
hitOptions.match = item => {
|
||||
if (!item.item || !item.item.selected) return;
|
||||
if (item.type === 'handle-out' || item.type === 'handle-in') {
|
||||
// Only hit test against handles that are visible, that is,
|
||||
// their segment is selected
|
||||
if (!item.segment.selected) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
} else {
|
||||
hitOptions.match = item => {
|
||||
if (item.type === 'handle-out' || item.type === 'handle-in') {
|
||||
// Only hit test against handles that are visible, that is,
|
||||
// their segment is selected
|
||||
if (!item.segment.selected) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return hitOptions;
|
||||
}
|
||||
setPrevHoveredItem (prevHoveredItem) {
|
||||
this.prevHoveredItem = prevHoveredItem;
|
||||
|
|
Loading…
Reference in a new issue