zuljaman-banner-components 1.0.10 → 1.0.11
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggableElement.d.ts","sourceRoot":"","sources":["../../../src/components/shared/DraggableElement.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IAGpB,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3D,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,IAAI,CAAC;IAGvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAG1D,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"DraggableElement.d.ts","sourceRoot":"","sources":["../../../src/components/shared/DraggableElement.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IAGpB,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3D,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,IAAI,CAAC;IAGvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAG1D,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA+jB5D,CAAC"}
|
|
@@ -33,12 +33,24 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
33
33
|
const justSelectedRef = react_1.default.useRef(false);
|
|
34
34
|
const justStoppedWithoutDragRef = react_1.default.useRef(false);
|
|
35
35
|
const dragStartPosRef = react_1.default.useRef({ x: 0, y: 0 });
|
|
36
|
+
const onDragMoveRef = react_1.default.useRef(onDragMove);
|
|
37
|
+
const onPositionChangeRef = react_1.default.useRef(onPositionChange);
|
|
38
|
+
const onWidthChangeRef = react_1.default.useRef(onWidthChange);
|
|
39
|
+
const scaleRef = react_1.default.useRef(scale);
|
|
40
|
+
const widthRef = react_1.default.useRef(width);
|
|
36
41
|
react_1.default.useEffect(() => {
|
|
37
42
|
currentRotationRef.current = rotation;
|
|
38
43
|
}, [rotation]);
|
|
39
44
|
react_1.default.useEffect(() => {
|
|
40
45
|
setCurrentPosition(position);
|
|
41
46
|
}, [position]);
|
|
47
|
+
react_1.default.useEffect(() => {
|
|
48
|
+
onDragMoveRef.current = onDragMove;
|
|
49
|
+
onPositionChangeRef.current = onPositionChange;
|
|
50
|
+
onWidthChangeRef.current = onWidthChange;
|
|
51
|
+
scaleRef.current = scale;
|
|
52
|
+
widthRef.current = width;
|
|
53
|
+
});
|
|
42
54
|
if (!enabled) {
|
|
43
55
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
44
56
|
}
|
|
@@ -161,16 +173,16 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
161
173
|
return;
|
|
162
174
|
const handleDragMove = (e) => {
|
|
163
175
|
hasDraggedRef.current = true;
|
|
164
|
-
const deltaX = (e.clientX - dragStartPosRef.current.x) /
|
|
165
|
-
const deltaY = (e.clientY - dragStartPosRef.current.y) /
|
|
176
|
+
const deltaX = (e.clientX - dragStartPosRef.current.x) / scaleRef.current;
|
|
177
|
+
const deltaY = (e.clientY - dragStartPosRef.current.y) / scaleRef.current;
|
|
166
178
|
const newPosition = {
|
|
167
179
|
x: startPositionRef.current.x + deltaX,
|
|
168
180
|
y: startPositionRef.current.y + deltaY,
|
|
169
181
|
};
|
|
170
182
|
setCurrentPosition(newPosition);
|
|
171
|
-
if (contentOnlyRef.current &&
|
|
183
|
+
if (contentOnlyRef.current && onDragMoveRef.current) {
|
|
172
184
|
const elementBounds = contentOnlyRef.current.getBoundingClientRect();
|
|
173
|
-
|
|
185
|
+
onDragMoveRef.current(elementId, elementBounds);
|
|
174
186
|
}
|
|
175
187
|
};
|
|
176
188
|
const handleDragEnd = () => {
|
|
@@ -181,14 +193,15 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
181
193
|
setIsDragging(false);
|
|
182
194
|
// Use callback form to get latest position
|
|
183
195
|
setCurrentPosition((pos) => {
|
|
184
|
-
|
|
196
|
+
var _a;
|
|
197
|
+
(_a = onPositionChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onPositionChangeRef, pos);
|
|
185
198
|
return pos;
|
|
186
199
|
});
|
|
187
200
|
// Auto-capture width if not explicitly set
|
|
188
|
-
if (
|
|
201
|
+
if (widthRef.current === undefined && contentOnlyRef.current && onWidthChangeRef.current) {
|
|
189
202
|
const currentWidth = contentOnlyRef.current.offsetWidth;
|
|
190
203
|
if (currentWidth > 0) {
|
|
191
|
-
|
|
204
|
+
onWidthChangeRef.current(Math.round(currentWidth));
|
|
192
205
|
}
|
|
193
206
|
}
|
|
194
207
|
};
|
|
@@ -198,7 +211,7 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
198
211
|
window.removeEventListener('mousemove', handleDragMove);
|
|
199
212
|
window.removeEventListener('mouseup', handleDragEnd);
|
|
200
213
|
};
|
|
201
|
-
}, [isDragging,
|
|
214
|
+
}, [isDragging, elementId]);
|
|
202
215
|
// Handle pre-drag mouse tracking
|
|
203
216
|
const handleMouseDownForDrag = react_1.default.useCallback((e) => {
|
|
204
217
|
const target = e.target;
|