fix issue with text selection
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
import {
|
||||
assignAttributes, cleanupElement, getElem, getRotationAngle, snapToGrid, walkTree,
|
||||
isNullish, preventClickDefault, setHref
|
||||
isNullish, preventClickDefault, setHref, getBBox
|
||||
} from './utilities.js';
|
||||
import {
|
||||
convertAttrs
|
||||
@@ -201,7 +201,7 @@ export const mouseMoveEvent = function (evt) {
|
||||
// the shape's coordinates
|
||||
tlist = selected.transform.baseVal;
|
||||
const hasMatrix = hasMatrixTransform(tlist);
|
||||
box = hasMatrix ? eventContext_.getInitBbox() : selected.getBBox();
|
||||
box = hasMatrix ? eventContext_.getInitBbox() : getBBox(selected);
|
||||
let left = box.x;
|
||||
let top = box.y;
|
||||
let { width, height } = box;
|
||||
@@ -478,7 +478,7 @@ export const mouseMoveEvent = function (evt) {
|
||||
|
||||
break;
|
||||
} case 'rotate': {
|
||||
box = selected.getBBox();
|
||||
box = getBBox(selected);
|
||||
cx = box.x + box.width / 2;
|
||||
cy = box.y + box.height / 2;
|
||||
const m = getMatrix(selected);
|
||||
@@ -1074,7 +1074,7 @@ export const mouseDownEvent = function (evt) {
|
||||
|
||||
// Getting the BBox from the selection box, since we know we
|
||||
// want to orient around it
|
||||
eventContext_.setInitBbox($id('selectedBox0').getBBox());
|
||||
eventContext_.setInitBbox(getBBox($id('selectedBox0')));
|
||||
const bb = {};
|
||||
for (const [ key, val ] of Object.entries(eventContext_.getInitBbox())) {
|
||||
bb[key] = val / currentZoom;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @copyright 2010 Jeff Schiller
|
||||
*/
|
||||
|
||||
import { getHref, setHref, getRotationAngle, isNullish } from './utilities.js';
|
||||
import { getHref, setHref, getRotationAngle, isNullish, getBBox } from './utilities.js';
|
||||
|
||||
/**
|
||||
* Group: Undo/Redo history management.
|
||||
@@ -330,7 +330,7 @@ export class ChangeElementCommand extends Command {
|
||||
if (!bChangedTransform) {
|
||||
const angle = getRotationAngle(this.elem);
|
||||
if (angle) {
|
||||
const bbox = this.elem.getBBox();
|
||||
const bbox = getBBox(this.elem);
|
||||
const cx = bbox.x + bbox.width / 2;
|
||||
const cy = bbox.y + bbox.height / 2;
|
||||
const rotate = [ 'rotate(', angle, ' ', cx, ',', cy, ')' ].join('');
|
||||
@@ -371,7 +371,7 @@ export class ChangeElementCommand extends Command {
|
||||
if (!bChangedTransform) {
|
||||
const angle = getRotationAngle(this.elem);
|
||||
if (angle) {
|
||||
const bbox = this.elem.getBBox();
|
||||
const bbox = getBBox(this.elem);
|
||||
const cx = bbox.x + bbox.width / 2;
|
||||
const cy = bbox.y + bbox.height / 2;
|
||||
const rotate = [ 'rotate(', angle, ' ', cx, ',', cy, ')' ].join('');
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from './math.js';
|
||||
import {
|
||||
assignAttributes, getElem, getRotationAngle, snapToGrid, isNullish,
|
||||
getBBox as utilsGetBBox
|
||||
getBBox
|
||||
} from './utilities.js';
|
||||
|
||||
let pathActionsContext_ = null;
|
||||
@@ -679,7 +679,7 @@ export const pathActionsMethod = (function () {
|
||||
|
||||
// const {item} = seg;
|
||||
const rubberBox = editorContext_.getRubberBox();
|
||||
const rbb = rubberBox.getBBox();
|
||||
const rbb = getBBox(rubberBox);
|
||||
|
||||
const pt = pathActionsContext_.getGripPt(seg);
|
||||
const ptBb = {
|
||||
@@ -770,7 +770,7 @@ export const pathActionsMethod = (function () {
|
||||
editorContext_.clearSelection();
|
||||
path.setPathContext();
|
||||
path.show(true).update();
|
||||
path.oldbbox = utilsGetBBox(path.elem);
|
||||
path.oldbbox = getBBox(path.elem);
|
||||
subpath = false;
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { NS } from "./namespaces.js";
|
||||
import {
|
||||
getBBox as utilsGetBBox,
|
||||
getBBox,
|
||||
getStrokedBBoxDefaultVisible
|
||||
} from "./utilities.js";
|
||||
import {
|
||||
@@ -286,7 +286,7 @@ export const getIntersectionListMethod = function (rect) {
|
||||
|
||||
let rubberBBox;
|
||||
if (!rect) {
|
||||
rubberBBox = selectionContext_.getRubberBox().getBBox();
|
||||
rubberBBox = getBBox(selectionContext_.getRubberBox());
|
||||
const bb = selectionContext_.getSVGContent().createSVGRect();
|
||||
|
||||
[ "x", "y", "width", "height", "top", "right", "bottom", "left" ].forEach(
|
||||
@@ -379,7 +379,7 @@ export const setRotationAngle = function (val, preventUndo) {
|
||||
val = Number.parseFloat(val);
|
||||
const elem = selectedElements[0];
|
||||
const oldTransform = elem.getAttribute("transform");
|
||||
const bbox = utilsGetBBox(elem);
|
||||
const bbox = getBBox(elem);
|
||||
const cx = bbox.x + bbox.width / 2;
|
||||
const cy = bbox.y + bbox.height / 2;
|
||||
const tlist = elem.transform.baseVal;
|
||||
|
||||
@@ -854,20 +854,6 @@ export const getBBoxWithTransform = function (elem, addSVGElementFromJson, pathA
|
||||
if (!goodBb) {
|
||||
const { matrix } = transformListToTransform(tlist);
|
||||
bb = transformBox(bb.x, bb.y, bb.width, bb.height, matrix).aabox;
|
||||
|
||||
// Old technique that was exceedingly slow with large documents.
|
||||
//
|
||||
// Accurate way to get BBox of rotated element in Firefox:
|
||||
// Put element in group and get its BBox
|
||||
//
|
||||
// Must use clone else FF freaks out
|
||||
// const clone = elem.cloneNode(true);
|
||||
// const g = document.createElementNS(NS.SVG, 'g');
|
||||
// const parent = elem.parentNode;
|
||||
// parent.append(g);
|
||||
// g.append(clone);
|
||||
// const bb2 = bboxToObj(g.getBBox());
|
||||
// g.remove();
|
||||
}
|
||||
}
|
||||
return bb;
|
||||
|
||||
Reference in New Issue
Block a user