mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-11 13:56:34 -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 { 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 {
|
import type {
|
||||||
ActiveTool,
|
ActiveTool,
|
||||||
@ -562,6 +567,9 @@ export const isTransparent = (color: string) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isAlwaysInsideBinding = (element: ExcalidrawBindableElement) =>
|
||||||
|
isImageElement(element);
|
||||||
|
|
||||||
export type ResolvablePromise<T> = Promise<T> & {
|
export type ResolvablePromise<T> = Promise<T> & {
|
||||||
resolve: [T] extends [undefined]
|
resolve: [T] extends [undefined]
|
||||||
? (value?: MaybePromise<Awaited<T>>) => void
|
? (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 {
|
import {
|
||||||
lineSegment,
|
lineSegment,
|
||||||
@ -318,7 +324,10 @@ const bindingStrategyForEndpointDragging = (
|
|||||||
|
|
||||||
// If the global bind mode is in free binding mode, just bind
|
// If the global bind mode is in free binding mode, just bind
|
||||||
// where the pointer is and keep the other end intact
|
// where the pointer is and keep the other end intact
|
||||||
if (globalBindMode === "inside") {
|
if (
|
||||||
|
globalBindMode === "inside" ||
|
||||||
|
(hovered && isAlwaysInsideBinding(hovered))
|
||||||
|
) {
|
||||||
current = hovered
|
current = hovered
|
||||||
? {
|
? {
|
||||||
element: hovered,
|
element: hovered,
|
||||||
@ -393,7 +402,6 @@ const bindingStrategyForEndpointDragging = (
|
|||||||
}
|
}
|
||||||
// The dragged point is inside the hovered bindable element
|
// The dragged point is inside the hovered bindable element
|
||||||
else {
|
else {
|
||||||
console.log(oppositeBinding);
|
|
||||||
// The opposite binding is on the same element
|
// The opposite binding is on the same element
|
||||||
// eslint-disable-next-line no-lonely-if
|
// eslint-disable-next-line no-lonely-if
|
||||||
if (oppositeBinding) {
|
if (oppositeBinding) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user