Skip to content

Commit

Permalink
Improve performances
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmi committed Jul 21, 2024
1 parent d6af915 commit 8726105
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/lib/board/Items/Item.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { memo } from "react";

import ResizeHandler from "./ResizeHandler";
import { css } from "goober";
import deepEqual from "fast-deep-equal";

import ResizeHandler from "./ResizeHandler";
import useMainStore from "../store/main";

const itemClass = css`
display: inline-block;
transition: transform 150ms;
Expand Down Expand Up @@ -184,6 +186,7 @@ const Item = ({
showResizeHandle = true,
}) => {
const itemWrapperRef = React.useRef(null);
const [uid] = useMainStore((state) => [state.config.uid]);

const {
component: Component = () => null,
Expand Down Expand Up @@ -244,6 +247,7 @@ const Item = ({
<div
style={{ transform: `rotate(${rotation}deg` }}
data-id={id}
id={`${uid}_${id}`}
className={className}
>
<div
Expand Down
6 changes: 2 additions & 4 deletions src/lib/board/Items/useItemActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ const useItemActions = () => {
getLinkedItems(getStoreItems(), getItemIds(), itemIds),
posDelta
);

updateItemExtent();
},
[getItemIds, getStoreItems, moveStoreItems, updateItemExtent]
[getItemIds, getStoreItems, moveStoreItems]
);

const putItemsOnTop = React.useCallback(
Expand Down Expand Up @@ -292,7 +290,7 @@ const useItemActions = () => {
});

insertItems(itemsWithPosition, beforeId);
placeItems(itemsToInsert.map((item) => item.id));
placeItems(itemsToInsert.map(({ id }) => id));
},
[getCenter, insertItems, placeItems]
);
Expand Down
6 changes: 6 additions & 0 deletions src/lib/board/useDim.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ const useDim = () => {
200
);

React.useEffect(() => {
window.debugUpdateExtent = () => updateItemExtent();
window.debugDisplayExtent = () =>
console.log(getConfiguration().itemExtent);
}, [getConfiguration, updateItemExtent]);

return {
setDim: setDimSafe,
rotateBoard,
Expand Down
1 change: 1 addition & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as useWire } from "@/hooks/useWire";
export { default as useItems } from "@/board/Items/useItems";
export { default as useDebouncedItems } from "@/board/Items/useDebouncedItems";
export { default as useSelectedItems } from "@/board/Items/useSelectedItems";
export { default as useGetSelectedItems } from "@/board/Items/useGetSelectedItems";
export { default as useItemActions } from "@/board/Items/useItemActions";
export { default as useItemInteraction } from "@/board/Items/useItemInteraction";
export { default as useAvailableActions } from "@/board/Items/useAvailableActions";
Expand Down

0 comments on commit 8726105

Please sign in to comment.