publ-echo-test 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
21
|
return t;
|
22
22
|
};
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
|
-
import React, { useRef, useState } from "react";
|
24
|
+
import React, { useEffect, useRef, useState } from "react";
|
25
25
|
import { DraggableCore } from "../Draggable";
|
26
26
|
import classNames from "../../external-lib/classnames";
|
27
27
|
import { calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcXY, clamp, resolveRowHeight, } from "./utils/calculateUtils";
|
@@ -38,6 +38,45 @@ var GridItem = function (_a) {
|
|
38
38
|
var _q = useState(false), isDragging = _q[0], setIsDragging = _q[1];
|
39
39
|
var _r = useState(false), isResizing = _r[0], setIsResizing = _r[1];
|
40
40
|
var elementRef = useRef(null);
|
41
|
+
var isSelected = className === null || className === void 0 ? void 0 : className.includes('react-grid-item-selected');
|
42
|
+
useEffect(function () {
|
43
|
+
var _a;
|
44
|
+
var targetNode = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.children[0].children[0];
|
45
|
+
if (!targetNode || isDragging || isResizing) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
// MutationObserver 콜백 함수
|
49
|
+
var callback = function (mutationsList, observer) {
|
50
|
+
for (var _i = 0, mutationsList_1 = mutationsList; _i < mutationsList_1.length; _i++) {
|
51
|
+
var mutation = mutationsList_1[_i];
|
52
|
+
if (mutation.type === 'attributes') {
|
53
|
+
if (mutation.attributeName === 'style') {
|
54
|
+
var height = targetNode.clientHeight;
|
55
|
+
console.log('Height changed:', height);
|
56
|
+
var handler = props['onResize'];
|
57
|
+
var prevW = props.w;
|
58
|
+
var prevH = props.h;
|
59
|
+
var _a = calcWH(getPositionParams(), {
|
60
|
+
width: targetNode.clientWidth,
|
61
|
+
height: height,
|
62
|
+
}, x, y, 'e', props.w, props.h), w_1 = _a.w, h_1 = _a.h;
|
63
|
+
var _b = getResizableXYPosition('e', w_1, h_1, prevW, prevH), newX = _b.newX, newY = _b.newY;
|
64
|
+
handler && handler(i, w_1, h_1, {}, newX, newY);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
};
|
69
|
+
// MutationObserver 인스턴스 생성
|
70
|
+
var observer = new MutationObserver(callback);
|
71
|
+
// 관찰할 DOM 변이 설정
|
72
|
+
var config = { attributes: true, childList: false, subtree: false, attributeFilter: ['style'] };
|
73
|
+
// 대상 노드와 설정으로 관찰 시작
|
74
|
+
observer.observe(targetNode, config);
|
75
|
+
// 정리 함수에서 MutationObserver 해제
|
76
|
+
return function () {
|
77
|
+
observer.disconnect();
|
78
|
+
};
|
79
|
+
}, [isSelected, isDragging, isResizing, props.w, props.h, x, y]);
|
41
80
|
// const moveDroppingItem = (prevProps: GridItemProps) => {
|
42
81
|
// const { droppingPosition } = props;
|
43
82
|
// if (!droppingPosition) return;
|