mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-10 13:26:11 -04:00
Images now always bind inside
This commit is contained in:
parent
fc350cf9f5
commit
4b3eef6099
@ -1,6 +1,11 @@
|
||||
import { average } from "@excalidraw/math";
|
||||
import { isImageElement } from "@excalidraw/element";
|
||||
|
||||
import type { FontFamilyValues, FontString } from "@excalidraw/element/types";
|
||||
import type {
|
||||
ExcalidrawBindableElement,
|
||||
FontFamilyValues,
|
||||
FontString,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import type {
|
||||
ActiveTool,
|
||||
@ -562,6 +567,9 @@ export const isTransparent = (color: string) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const isAlwaysInsideBinding = (element: ExcalidrawBindableElement) =>
|
||||
isImageElement(element);
|
||||
|
||||
export type ResolvablePromise<T> = Promise<T> & {
|
||||
resolve: [T] extends [undefined]
|
||||
? (value?: MaybePromise<Awaited<T>>) => void
|
||||
|
@ -1,4 +1,10 @@
|
||||
import { KEYS, arrayToMap, invariant, tupleToCoors } from "@excalidraw/common";
|
||||
import {
|
||||
KEYS,
|
||||
arrayToMap,
|
||||
invariant,
|
||||
isAlwaysInsideBinding,
|
||||
tupleToCoors,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import {
|
||||
lineSegment,
|
||||
@ -318,7 +324,10 @@ const bindingStrategyForEndpointDragging = (
|
||||
|
||||
// If the global bind mode is in free binding mode, just bind
|
||||
// where the pointer is and keep the other end intact
|
||||
if (globalBindMode === "inside") {
|
||||
if (
|
||||
globalBindMode === "inside" ||
|
||||
(hovered && isAlwaysInsideBinding(hovered))
|
||||
) {
|
||||
current = hovered
|
||||
? {
|
||||
element: hovered,
|
||||
@ -393,7 +402,6 @@ const bindingStrategyForEndpointDragging = (
|
||||
}
|
||||
// The dragged point is inside the hovered bindable element
|
||||
else {
|
||||
console.log(oppositeBinding);
|
||||
// The opposite binding is on the same element
|
||||
// eslint-disable-next-line no-lonely-if
|
||||
if (oppositeBinding) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user