fix: pending review fixes for sticky notes (#4493)

This commit is contained in:
Aakansha Doshi 2021-12-28 16:24:44 +05:30 committed by GitHub
parent bae0e985b2
commit 63ce5b82d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 26 deletions

View File

@ -2101,10 +2101,9 @@ class App extends React.Component<AppProps, AppState> {
const container = const container =
shouldBind || parentCenterPosition shouldBind || parentCenterPosition
? getElementContainingPosition( ? getElementContainingPosition(
this.scene.getElements(), this.scene.getElements().filter((ele) => !isTextElement(ele)),
sceneX, sceneX,
sceneY, sceneY,
"text",
) )
: null; : null;

View File

@ -46,8 +46,7 @@ const isElementDraggableFromInside = (
return true; return true;
} }
const isDraggableFromInside = const isDraggableFromInside =
!isTransparent(element.backgroundColor) || !isTransparent(element.backgroundColor) || hasBoundTextElement(element);
(isTransparent(element.backgroundColor) && hasBoundTextElement(element));
if (element.type === "line") { if (element.type === "line") {
return isDraggableFromInside && isPathALoop(element.points); return isDraggableFromInside && isPathALoop(element.points);
} }

View File

@ -322,25 +322,11 @@ export const charWidth = (() => {
return cachedCharWidth[font][ascii]; return cachedCharWidth[font][ascii];
}; };
const updateCache = (char: string, font: FontString) => {
const ascii = char.charCodeAt(0);
if (!cachedCharWidth[font][ascii]) {
cachedCharWidth[font][ascii] = calculate(char, font);
}
};
const clearCacheforFont = (font: FontString) => {
cachedCharWidth[font] = [];
};
const getCache = (font: FontString) => { const getCache = (font: FontString) => {
return cachedCharWidth[font]; return cachedCharWidth[font];
}; };
return { return {
calculate, calculate,
updateCache,
clearCacheforFont,
getCache, getCache,
}; };
})(); })();

View File

@ -75,7 +75,6 @@ export const getElementContainingPosition = (
elements: readonly ExcalidrawElement[], elements: readonly ExcalidrawElement[],
x: number, x: number,
y: number, y: number,
excludedType?: ExcalidrawElement["type"],
) => { ) => {
let hitElement = null; let hitElement = null;
// We need to to hit testing from front (end of the array) to back (beginning of the array) // We need to to hit testing from front (end of the array) to back (beginning of the array)
@ -84,13 +83,7 @@ export const getElementContainingPosition = (
continue; continue;
} }
const [x1, y1, x2, y2] = getElementAbsoluteCoords(elements[index]); const [x1, y1, x2, y2] = getElementAbsoluteCoords(elements[index]);
if ( if (x1 < x && x < x2 && y1 < y && y < y2) {
x1 < x &&
x < x2 &&
y1 < y &&
y < y2 &&
elements[index].type !== excludedType
) {
hitElement = elements[index]; hitElement = elements[index];
break; break;
} }