@h4md1/visual-image-tool 0.1.5 → 0.2.0
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.
- package/README.md +95 -86
- package/dist/visual-image-tool.esm.js +50 -7
- package/dist/visual-image-tool.esm.js.map +1 -1
- package/dist/visual-image-tool.js +50 -7
- package/dist/visual-image-tool.js.map +1 -1
- package/dist/visual-image-tool.umd.js +1 -1
- package/dist/visual-image-tool.umd.js.map +1 -1
- package/package.json +5 -3
- package/src/visual-image-tool.js +50 -7
package/src/visual-image-tool.js
CHANGED
|
@@ -59,7 +59,8 @@ class VisualImageTool {
|
|
|
59
59
|
},
|
|
60
60
|
...options.cropZone
|
|
61
61
|
},
|
|
62
|
-
onChange: options.onChange || (() => {})
|
|
62
|
+
onChange: options.onChange || (() => {}),
|
|
63
|
+
debug: options.debug || false
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
// État interne
|
|
@@ -536,10 +537,31 @@ class VisualImageTool {
|
|
|
536
537
|
}
|
|
537
538
|
|
|
538
539
|
const scaled = this._toScaledCoords(clampedX, clampedY);
|
|
539
|
-
|
|
540
|
+
|
|
541
|
+
// LOGGING: Validate padding offset
|
|
542
|
+
if (this.options.debug) {
|
|
543
|
+
const container = this.imageElement.parentNode;
|
|
544
|
+
const computedStyle = window.getComputedStyle(container);
|
|
545
|
+
const paddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
546
|
+
const paddingTop = parseFloat(computedStyle.paddingTop);
|
|
547
|
+
console.log('[FocusMarker] scaled:', scaled, 'paddingLeft:', paddingLeft, 'paddingTop:', paddingTop, 'containerRect:', container.getBoundingClientRect());
|
|
548
|
+
}
|
|
549
|
+
|
|
540
550
|
// Ajuster pour centrer le marqueur
|
|
541
|
-
|
|
542
|
-
|
|
551
|
+
// Adjust for container padding (use unique variable names)
|
|
552
|
+
let focusPaddingLeft = 0, focusPaddingTop = 0;
|
|
553
|
+
{
|
|
554
|
+
const container = this.imageElement.parentNode;
|
|
555
|
+
const computedStyle = window.getComputedStyle(container);
|
|
556
|
+
focusPaddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
557
|
+
focusPaddingTop = parseFloat(computedStyle.paddingTop);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
this.state.focusMarker.style.left = (scaled.x + focusPaddingLeft - this.state.focusMarker.offsetWidth / 2) + 'px';
|
|
561
|
+
this.state.focusMarker.style.top = (scaled.y + focusPaddingTop - this.state.focusMarker.offsetHeight / 2) + 'px';
|
|
562
|
+
if (this.options.debug) {
|
|
563
|
+
console.log('[FocusMarker] style.left:', this.state.focusMarker.style.left, 'style.top:', this.state.focusMarker.style.top);
|
|
564
|
+
}
|
|
543
565
|
}
|
|
544
566
|
|
|
545
567
|
/**
|
|
@@ -566,12 +588,33 @@ class VisualImageTool {
|
|
|
566
588
|
const scaled = this._toScaledCoords(clampedX, clampedY);
|
|
567
589
|
const scaledWidth = clampedWidth * this.state.scaleX;
|
|
568
590
|
const scaledHeight = clampedHeight * this.state.scaleY;
|
|
569
|
-
|
|
591
|
+
|
|
592
|
+
// LOGGING: Validate padding offset
|
|
593
|
+
if (this.options.debug) {
|
|
594
|
+
const container = this.imageElement.parentNode;
|
|
595
|
+
const computedStyle = window.getComputedStyle(container);
|
|
596
|
+
const paddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
597
|
+
const paddingTop = parseFloat(computedStyle.paddingTop);
|
|
598
|
+
console.log('[CropOverlay] scaled:', scaled, 'paddingLeft:', paddingLeft, 'paddingTop:', paddingTop, 'containerRect:', container.getBoundingClientRect());
|
|
599
|
+
}
|
|
600
|
+
|
|
570
601
|
// Mettre à jour l'overlay
|
|
571
|
-
|
|
572
|
-
|
|
602
|
+
// Adjust for container padding (use unique variable names)
|
|
603
|
+
let cropPaddingLeft = 0, cropPaddingTop = 0;
|
|
604
|
+
{
|
|
605
|
+
const container = this.imageElement.parentNode;
|
|
606
|
+
const computedStyle = window.getComputedStyle(container);
|
|
607
|
+
cropPaddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
608
|
+
cropPaddingTop = parseFloat(computedStyle.paddingTop);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
this.state.cropOverlay.style.left = (scaled.x + cropPaddingLeft) + 'px';
|
|
612
|
+
this.state.cropOverlay.style.top = (scaled.y + cropPaddingTop) + 'px';
|
|
573
613
|
this.state.cropOverlay.style.width = scaledWidth + 'px';
|
|
574
614
|
this.state.cropOverlay.style.height = scaledHeight + 'px';
|
|
615
|
+
if (this.options.debug) {
|
|
616
|
+
console.log('[CropOverlay] style.left:', this.state.cropOverlay.style.left, 'style.top:', this.state.cropOverlay.style.top);
|
|
617
|
+
}
|
|
575
618
|
}
|
|
576
619
|
|
|
577
620
|
/**
|