This commit is contained in:
DD Liu 2019-11-13 22:22:31 -05:00
parent 3733fb4148
commit e16a85adb1
3 changed files with 12 additions and 8 deletions

View file

@ -82,10 +82,10 @@ const setGuideItem = function (item) {
item.guide = true;
if (isGroupItem(item)) {
for (let i = 0; i < item.children.length; i++) {
setGuideItem(item.children[i])
setGuideItem(item.children[i]);
}
}
}
};
/**
* Removes the guide layers, e.g. for purposes of exporting the image. Must call showGuideLayers to re-add them.

View file

@ -75,11 +75,11 @@ class MoveTool {
this.selectedItems = this.mode === Modes.RESHAPE ? getSelectedLeafItems() : getSelectedRootItems();
let selectionBounds;
for (const item of this.selectedItems) {
if (!selectionBounds) {
selectionBounds = item.bounds;
for (const selectedItem of this.selectedItems) {
if (selectionBounds) {
selectionBounds = selectionBounds.unite(selectedItem.bounds);
} else {
selectionBounds = selectionBounds.unite(item.bounds);
selectionBounds = selectedItem.bounds;
}
}
this.selectionCenter = selectionBounds.center;
@ -128,7 +128,11 @@ class MoveTool {
// crosshair to line up.
const center = new paper.Point(ART_BOARD_WIDTH / 2, ART_BOARD_HEIGHT / 2);
if (!event.modifiers.shift && this.mode === Modes.SELECT) {
if (checkPointsClose(this.selectionCenter.add(dragVector), center, SNAPPING_THRESHOLD / paper.view.zoom /* threshold */)) {
if (checkPointsClose(
this.selectionCenter.add(dragVector),
center,
SNAPPING_THRESHOLD / paper.view.zoom /* threshold */)) {
snapVector = center.subtract(this.selectionCenter);
}
}

View file

@ -39,7 +39,7 @@ const _resizeCrosshair = () => {
getBackgroundGuideLayer().dragCrosshair.scale(
CROSSHAIR_SIZE / getBackgroundGuideLayer().dragCrosshair.bounds.width / paper.view.zoom);
}
}
};
// Zoom keeping a project-space point fixed.
// This article was helpful http://matthiasberth.com/tech/stable-zoom-and-pan-in-paperjs