zuljaman-banner-components 1.0.8 → 1.0.9
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,CAyhB5D,CAAC"}
|
|
@@ -170,47 +170,49 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
170
170
|
startPositionRef.current = { x: currentPosition.x, y: currentPosition.y };
|
|
171
171
|
setIsDragging(true);
|
|
172
172
|
};
|
|
173
|
-
|
|
173
|
+
react_1.default.useEffect(() => {
|
|
174
174
|
if (!isDragging)
|
|
175
175
|
return;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
const handleDragMove = (e) => {
|
|
177
|
+
hasDraggedRef.current = true;
|
|
178
|
+
const deltaX = (e.clientX - dragStartPosRef.current.x) / scale;
|
|
179
|
+
const deltaY = (e.clientY - dragStartPosRef.current.y) / scale;
|
|
180
|
+
const newPosition = {
|
|
181
|
+
x: startPositionRef.current.x + deltaX,
|
|
182
|
+
y: startPositionRef.current.y + deltaY,
|
|
183
|
+
};
|
|
184
|
+
setCurrentPosition(newPosition);
|
|
185
|
+
if (contentOnlyRef.current && onDragMove) {
|
|
186
|
+
const elementBounds = contentOnlyRef.current.getBoundingClientRect();
|
|
187
|
+
onDragMove(elementId, elementBounds);
|
|
188
|
+
}
|
|
182
189
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const handleDragEnd = () => {
|
|
190
|
-
// If we didn't actually drag, set flag to prevent onClick from toggling
|
|
191
|
-
if (!hasDraggedRef.current) {
|
|
192
|
-
justStoppedWithoutDragRef.current = true;
|
|
193
|
-
}
|
|
194
|
-
setIsDragging(false);
|
|
195
|
-
onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(currentPosition);
|
|
196
|
-
// Auto-capture width if not explicitly set
|
|
197
|
-
if (width === undefined && contentOnlyRef.current && onWidthChange) {
|
|
198
|
-
const currentWidth = contentOnlyRef.current.offsetWidth;
|
|
199
|
-
if (currentWidth > 0) {
|
|
200
|
-
onWidthChange(Math.round(currentWidth));
|
|
190
|
+
const handleDragEnd = () => {
|
|
191
|
+
// If we didn't actually drag, set flag to prevent onClick from toggling
|
|
192
|
+
if (!hasDraggedRef.current) {
|
|
193
|
+
justStoppedWithoutDragRef.current = true;
|
|
201
194
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
195
|
+
setIsDragging(false);
|
|
196
|
+
// Use callback form to get latest position
|
|
197
|
+
setCurrentPosition((pos) => {
|
|
198
|
+
onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(pos);
|
|
199
|
+
return pos;
|
|
200
|
+
});
|
|
201
|
+
// Auto-capture width if not explicitly set
|
|
202
|
+
if (width === undefined && contentOnlyRef.current && onWidthChange) {
|
|
203
|
+
const currentWidth = contentOnlyRef.current.offsetWidth;
|
|
204
|
+
if (currentWidth > 0) {
|
|
205
|
+
onWidthChange(Math.round(currentWidth));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
window.addEventListener('mousemove', handleDragMove);
|
|
210
|
+
window.addEventListener('mouseup', handleDragEnd);
|
|
211
|
+
return () => {
|
|
212
|
+
window.removeEventListener('mousemove', handleDragMove);
|
|
213
|
+
window.removeEventListener('mouseup', handleDragEnd);
|
|
214
|
+
};
|
|
215
|
+
}, [isDragging, scale, onDragMove, onPositionChange, onWidthChange, width, elementId]);
|
|
214
216
|
// Selection handlers
|
|
215
217
|
const handleElementClick = (e) => {
|
|
216
218
|
// Don't toggle selection if clicking rotation or width handles
|