Fix multielements (#987)

This commit is contained in:
Pete Hunt 2020-03-17 11:01:11 -07:00 committed by GitHub
parent 0dc07135b7
commit b603337c3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 56 deletions

View file

@ -2,6 +2,7 @@ import { ExcalidrawElement } from "./types";
import { randomSeed } from "roughjs/bin/math";
import { invalidateShapeForElement } from "../renderer/renderElement";
import { globalSceneState } from "../scene";
import { getSizeFromPoints } from "../points";
type ElementUpdate<TElement extends ExcalidrawElement> = Omit<
Partial<TElement>,
@ -18,6 +19,10 @@ export function mutateElement<TElement extends ExcalidrawElement>(
) {
const mutableElement = element as any;
if (typeof updates.points !== "undefined") {
updates = { ...getSizeFromPoints(updates.points!), ...updates };
}
for (const key in updates) {
const value = (updates as any)[key];
if (typeof value !== "undefined") {