point-focus 1.0.5 → 2.0.0-beta.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/dist/index.cjs CHANGED
@@ -30,47 +30,49 @@ function styleInject(css, ref) {
30
30
  }
31
31
  }
32
32
 
33
- var css_248z = ":root{--button-icon-color:#1e1c1c;--loader-background:#19181891;--loader-color:#fff}.styles-module_c-point-focus__Glxyg{align-items:center;cursor:zoom-in;display:inline-block;display:flex;height:100%;justify-content:center;margin:0;overflow:hidden;position:relative;width:100%}.styles-module_c-point-focus__Glxyg[data-movetype=follow] .styles-module_c-point-focus__zoom-img__HP-hu{cursor:crosshair}.styles-module_c-point-focus__Glxyg[data-movetype=drag] .styles-module_c-point-focus__zoom-img__HP-hu{cursor:grab}.styles-module_c-point-focus__overlay__T8nCD{inset:0;pointer-events:none;position:absolute;z-index:1}.styles-module_c-point-focus__placeholder__dHGk6{align-items:center;background:var(--loader-background);display:flex;inset:0;justify-content:center;position:absolute;z-index:2}.styles-module_c-point-focus__img__jCS0m{-webkit-user-drag:none;aspect-ratio:4/3;display:block;height:100%;object-fit:contain;opacity:1;pointer-events:none;transition:opacity 0ms linear var(--fade-duration),visibility 0ms linear var(--fade-duration);user-select:none;visibility:visible;width:100%}.styles-module_c-point-focus__img__jCS0m[data-hidden=true]{opacity:0;visibility:hidden}.styles-module_c-point-focus__zoom-img__HP-hu{-webkit-user-drag:none;-webkit-touch-callout:none;display:block;left:0;max-width:none!important;opacity:0;pointer-events:none;position:absolute;top:0;transform:translate(0);user-select:none;visibility:hidden;width:auto!important;will-change:transform}.styles-module_c-point-focus__zoom-img__HP-hu[data-visible=true]{cursor:zoom-out;opacity:1;pointer-events:auto;touch-action:none;visibility:visible}.styles-module_c-point-focus__button__oCELz{align-items:center;appearance:none;background:transparent;border:none;cursor:pointer;display:flex;justify-content:center;opacity:0;outline:none;padding:.3rem;position:absolute;right:2%;text-decoration:none;top:2%;transform-origin:center center;visibility:hidden}.styles-module_c-point-focus__button__oCELz[data-visible=true]{opacity:1;visibility:visible}.styles-module_c-point-focus__button__oCELz svg{filter:drop-shadow(0 0 10px rgba(0,0,0,.7));height:1rem;transform-origin:center;transition:transform .2s ease-in-out;width:1rem}.styles-module_c-point-focus__button__oCELz svg path{fill:var(--button-icon-color)}.styles-module_c-point-focus__button__oCELz:hover svg{transform:scale(1.2)}.styles-module_c-point-focus__button__oCELz:active{appearance:none;background:transparent;border:none;outline:none}.styles-module_c-point-focus__button__oCELz:active svg{transform:scale(1)}.styles-module_c-point-focus__loader__AIAkB{display:inline-block;height:48px;position:relative;width:48px}.styles-module_c-point-focus__loader__AIAkB:after,.styles-module_c-point-focus__loader__AIAkB:before{animation:styles-module_animloader__7LeVS 2s linear infinite;border:2px solid var(--loader-color);border-radius:50%;box-sizing:border-box;content:\"\";height:48px;left:0;position:absolute;top:0;width:48px}.styles-module_c-point-focus__loader__AIAkB:after{animation-delay:1s}@keyframes styles-module_animloader__7LeVS{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(2)}}.styles-module_c-point-focus__Glxyg .styles-module_c-fp-fallback-image__sROkG{height:100%;inset:0;object-fit:cover;object-position:center center;position:absolute;width:100%;z-index:2}";
34
- var styles = {"c-point-focus":"styles-module_c-point-focus__Glxyg","c-point-focus__zoom-img":"styles-module_c-point-focus__zoom-img__HP-hu","c-point-focus__overlay":"styles-module_c-point-focus__overlay__T8nCD","c-point-focus__placeholder":"styles-module_c-point-focus__placeholder__dHGk6","c-point-focus__img":"styles-module_c-point-focus__img__jCS0m","c-point-focus__button":"styles-module_c-point-focus__button__oCELz","c-point-focus__loader":"styles-module_c-point-focus__loader__AIAkB","animloader":"styles-module_animloader__7LeVS","c-fp-fallback-image":"styles-module_c-fp-fallback-image__sROkG"};
33
+ var css_248z = ":root{--button-icon-color:#1e1c1c;--loader-background:#19181891;--loader-color:#fff}point-focus-image{display:block}.c-point-focus{align-items:center;cursor:zoom-in;display:flex;height:100%;justify-content:center;margin:0;overflow:hidden;position:relative;width:100%;&[data-movetype=follow] .c-point-focus__zoom-img{cursor:crosshair}&[data-movetype=drag] .c-point-focus__zoom-img{cursor:grab}&:focus-visible{outline:.125rem solid currentColor;outline-offset:.125rem}}.c-point-focus__overlay{inset:0;pointer-events:none;position:absolute;z-index:1}.c-point-focus__placeholder{align-items:center;background:var(--loader-background);display:flex;inset:0;justify-content:center;position:absolute;z-index:2;&[hidden]{display:none}}.c-point-focus__img{-webkit-user-drag:none;aspect-ratio:4/3;display:block;height:100%;object-fit:contain;opacity:1;pointer-events:none;transition-delay:var(--fade-duration,0ms);transition-duration:0ms;transition-property:opacity,visibility;transition-timing-function:linear;user-select:none;visibility:visible;width:100%;&[data-hidden=true]{opacity:0;visibility:hidden}}.c-point-focus__zoom-img{-webkit-user-drag:none;-webkit-touch-callout:none;display:block;left:0;max-width:none!important;opacity:0;pointer-events:none;position:absolute;top:0;transform-origin:top left;transition-duration:var(--fade-duration,.15s);transition-property:opacity,visibility;transition-timing-function:linear;user-select:none;visibility:hidden;width:auto!important;will-change:transform;&[data-visible=true]{cursor:zoom-out;opacity:1;pointer-events:auto;touch-action:none;visibility:visible}}.c-point-focus__button{align-items:center;appearance:none;background:transparent;border:none;cursor:pointer;display:flex;justify-content:center;opacity:0;outline:none;padding:.3rem;position:absolute;right:2%;text-decoration:none;top:2%;transform-origin:center center;transition-duration:var(--fade-duration,.15s);transition-property:opacity,visibility;transition-timing-function:linear;visibility:hidden;z-index:3;&[data-visible=true]{opacity:1;visibility:visible}&:focus-visible{outline:.125rem solid currentColor}& svg{filter:drop-shadow(0 0 .625rem rgba(0,0,0,.7));height:1rem;transform-origin:center;transition:transform .2s ease-in-out;width:1rem;& path{fill:var(--button-icon-color)}}&:hover svg{transform:scale(1.2)}&:active svg{transform:scale(1)}}.c-point-focus__loader{display:inline-block;height:3rem;position:relative;width:3rem;&:after,&:before{animation:c-point-focus-loader 2s linear infinite;border:.125rem solid var(--loader-color);border-radius:50%;box-sizing:border-box;content:\"\";height:3rem;left:0;position:absolute;top:0;width:3rem}&:after{animation-delay:1s}}.c-point-focus .c-fp-fallback-image{height:100%;inset:0;object-fit:cover;object-position:center center;position:absolute;width:100%;z-index:2}@keyframes c-point-focus-loader{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(2)}}@media (prefers-reduced-motion:reduce){.c-point-focus__button,.c-point-focus__img,.c-point-focus__zoom-img{transition-duration:0ms}.c-point-focus__loader:after,.c-point-focus__loader:before{animation-duration:0s}}";
35
34
  styleInject(css_248z);
36
35
 
37
- function isTouchEvent(e) {
38
- return 'touches' in e || ('nativeEvent' in e && 'touches' in e.nativeEvent);
36
+ const EMPTY_BOUNDS = { left: 0, top: 0, width: 0, height: 0 };
37
+ function isTouchEvent(event) {
38
+ return 'touches' in event;
39
39
  }
40
- // Defaulted values to 0 to make the functions SSR safe
41
- function getPageCoords(e, fallbackElement) {
42
- if ('touches' in e && e.touches && e.touches.length > 0) {
43
- return { x: e.touches[0].pageX, y: e.touches[0].pageY };
40
+ function getPageCoords(source, fallbackElement) {
41
+ const event = source;
42
+ if (event.touches && event.touches.length > 0) {
43
+ return { x: event.touches[0].pageX, y: event.touches[0].pageY };
44
44
  }
45
- else if ('pageX' in e && 'pageY' in e) {
46
- return { x: e.pageX, y: e.pageY }; // Could further narrow with type guards
45
+ if (typeof event.pageX === 'number' && typeof event.pageY === 'number') {
46
+ return { x: event.pageX, y: event.pageY };
47
47
  }
48
- else if (fallbackElement) {
49
- const rect = fallbackElement.getBoundingClientRect();
50
- return {
51
- x: rect.left + rect.width / 2,
52
- y: rect.top + rect.height / 2,
53
- };
48
+ if (fallbackElement) {
49
+ return getElementCenter(fallbackElement);
54
50
  }
55
51
  return { x: 0, y: 0 };
56
52
  }
57
- const getOffsets = (pageX, pageY, left, top) => {
58
- return {
59
- x: pageX - left,
60
- y: pageY - top,
61
- };
62
- };
63
- const getBounds = (container) => {
64
- return container ? container.getBoundingClientRect() : { width: 0, height: 0, left: 0, top: 0 };
65
- };
66
- const getRatios = (bounds, natural, zoomScale) => {
67
- const scaledWidth = natural.width * zoomScale;
68
- const scaledHeight = natural.height * zoomScale;
53
+ function getElementCenter(element) {
54
+ const rect = element.getBoundingClientRect();
55
+ const scrollX = typeof window === 'undefined' ? 0 : window.scrollX;
56
+ const scrollY = typeof window === 'undefined' ? 0 : window.scrollY;
57
+ return { x: rect.left + scrollX + rect.width / 2, y: rect.top + scrollY + rect.height / 2 };
58
+ }
59
+ function getOffsets(pageX, pageY, left, top) {
60
+ return { x: pageX - left, y: pageY - top };
61
+ }
62
+ function getBounds(container) {
63
+ if (!container)
64
+ return { ...EMPTY_BOUNDS };
65
+ const { left, top, width, height } = container.getBoundingClientRect();
66
+ return { left, top, width, height };
67
+ }
68
+ function getRatios(bounds, natural, zoomScale) {
69
+ if (bounds.width === 0 || bounds.height === 0)
70
+ return { x: 0, y: 0 };
69
71
  return {
70
- x: (scaledWidth - bounds.width) / bounds.width,
71
- y: (scaledHeight - bounds.height) / bounds.height,
72
+ x: (natural.width * zoomScale - bounds.width) / bounds.width,
73
+ y: (natural.height * zoomScale - bounds.height) / bounds.height,
72
74
  };
73
- };
75
+ }
74
76
  function clampToBounds(left, top, bounds) {
75
77
  return {
76
78
  left: Math.max(Math.min(left, bounds.maxLeft), bounds.minLeft),
@@ -78,26 +80,157 @@ function clampToBounds(left, top, bounds) {
78
80
  };
79
81
  }
80
82
  function calculateDragPosition(pageX, pageY, offsets) {
81
- return {
82
- left: pageX - offsets.x,
83
- top: pageY - offsets.y,
84
- };
83
+ return { left: pageX - offsets.x, top: pageY - offsets.y };
85
84
  }
86
- const getDefaults = () => {
87
- const defaultCoordinates = { x: 0, y: 0 };
88
- return {
89
- onLoadCallback: null,
90
- bounds: { width: 0, height: 0, left: 0, top: 0 },
91
- offsets: defaultCoordinates,
92
- ratios: defaultCoordinates,
93
- scaledDimensions: { width: 0, height: 0 },
94
- dragStartCoords: defaultCoordinates,
95
- wasDragging: false,
96
- velocity: { vx: 0, vy: 0 },
97
- prevDragCoords: { x: 0, y: 0, time: 0 },
98
- lastDragCoords: { x: 0, y: 0, time: 0 },
99
- };
100
- };
85
+ function clampZoomScale(zoomScale) {
86
+ return Math.max(1, Math.min(zoomScale, 5));
87
+ }
88
+
89
+ const FRAME_SECONDS = 1 / 60;
90
+ const DRAG_THRESHOLD_PX = 3;
91
+ class ZoomEngine {
92
+ onPosition;
93
+ friction;
94
+ minVelocity;
95
+ now;
96
+ bounds = { ...EMPTY_BOUNDS };
97
+ ratios = { x: 0, y: 0 };
98
+ pageOffsets = { x: 0, y: 0 };
99
+ dragOffsets = { x: 0, y: 0 };
100
+ dragOrigin = { x: 0, y: 0 };
101
+ previousSample = null;
102
+ lastSample = null;
103
+ frameId = null;
104
+ dragging = false;
105
+ dragMoved = false;
106
+ current = { left: 0, top: 0 };
107
+ constructor({ onPosition, friction = 0.95, minVelocity = 10, now = () => Date.now() }) {
108
+ this.onPosition = onPosition;
109
+ this.friction = friction;
110
+ this.minVelocity = minVelocity;
111
+ this.now = now;
112
+ }
113
+ get position() {
114
+ return { ...this.current };
115
+ }
116
+ get isDragging() {
117
+ return this.dragging;
118
+ }
119
+ get containerBounds() {
120
+ return { ...this.bounds };
121
+ }
122
+ measure(container, natural, zoomScale) {
123
+ this.bounds = getBounds(container);
124
+ this.ratios = getRatios(this.bounds, natural, zoomScale);
125
+ }
126
+ startFollow(pageX, pageY, container) {
127
+ if (typeof window === 'undefined' || !container) {
128
+ this.bounds = { ...EMPTY_BOUNDS };
129
+ this.pageOffsets = { x: 0, y: 0 };
130
+ this.setPosition({ left: 0, top: 0 });
131
+ return;
132
+ }
133
+ this.bounds = getBounds(container);
134
+ this.pageOffsets = getOffsets(window.scrollX, window.scrollY, -this.bounds.left, -this.bounds.top);
135
+ this.follow(pageX, pageY);
136
+ }
137
+ follow(pageX, pageY) {
138
+ const { left, top } = calculateDragPosition(pageX, pageY, this.pageOffsets);
139
+ const clamped = clampToBounds(left, top, { minLeft: 0, maxLeft: this.bounds.width, minTop: 0, maxTop: this.bounds.height });
140
+ this.setPosition({ left: clamped.left * -this.ratios.x, top: clamped.top * -this.ratios.y });
141
+ }
142
+ beginDrag(pageX, pageY) {
143
+ this.cancelInertia();
144
+ this.dragging = true;
145
+ this.dragMoved = false;
146
+ this.dragOrigin = { x: pageX, y: pageY };
147
+ this.dragOffsets = getOffsets(pageX, pageY, this.current.left, this.current.top);
148
+ this.previousSample = null;
149
+ this.lastSample = null;
150
+ }
151
+ moveDrag(pageX, pageY) {
152
+ if (!this.dragging)
153
+ return;
154
+ this.previousSample = this.lastSample;
155
+ this.lastSample = { x: pageX, y: pageY, time: this.now() };
156
+ if (Math.hypot(pageX - this.dragOrigin.x, pageY - this.dragOrigin.y) > DRAG_THRESHOLD_PX) {
157
+ this.dragMoved = true;
158
+ }
159
+ const { left, top } = calculateDragPosition(pageX, pageY, this.dragOffsets);
160
+ this.setPosition(clampToBounds(left, top, this.dragLimits()));
161
+ }
162
+ endDrag(withInertia) {
163
+ if (!this.dragging)
164
+ return null;
165
+ this.dragging = false;
166
+ const velocity = this.releaseVelocity();
167
+ const final = { x: this.current.left, y: this.current.top };
168
+ if (withInertia)
169
+ this.startInertia(velocity);
170
+ return { velocity, final, moved: this.dragMoved };
171
+ }
172
+ reset() {
173
+ this.cancelInertia();
174
+ this.dragging = false;
175
+ this.dragMoved = false;
176
+ this.previousSample = null;
177
+ this.lastSample = null;
178
+ this.setPosition({ left: 0, top: 0 });
179
+ }
180
+ destroy() {
181
+ this.cancelInertia();
182
+ this.dragging = false;
183
+ }
184
+ dragLimits() {
185
+ return {
186
+ minLeft: this.bounds.width * -this.ratios.x,
187
+ maxLeft: 0,
188
+ minTop: this.bounds.height * -this.ratios.y,
189
+ maxTop: 0,
190
+ };
191
+ }
192
+ releaseVelocity() {
193
+ const last = this.lastSample;
194
+ const previous = this.previousSample;
195
+ if (!last || !previous)
196
+ return { vx: 0, vy: 0 };
197
+ const seconds = (last.time - previous.time) / 1000;
198
+ if (seconds <= 0)
199
+ return { vx: 0, vy: 0 };
200
+ return { vx: (last.x - previous.x) / seconds, vy: (last.y - previous.y) / seconds };
201
+ }
202
+ startInertia(initial) {
203
+ const limits = this.dragLimits();
204
+ let { vx, vy } = initial;
205
+ let { left, top } = this.current;
206
+ const step = () => {
207
+ vx *= this.friction;
208
+ vy *= this.friction;
209
+ left += vx * FRAME_SECONDS;
210
+ top += vy * FRAME_SECONDS;
211
+ const clamped = clampToBounds(left, top, limits);
212
+ this.setPosition(clamped);
213
+ if (Math.abs(vx) > this.minVelocity || Math.abs(vy) > this.minVelocity) {
214
+ this.frameId = requestAnimationFrame(step);
215
+ }
216
+ else {
217
+ this.frameId = null;
218
+ }
219
+ };
220
+ this.frameId = requestAnimationFrame(step);
221
+ }
222
+ cancelInertia() {
223
+ if (this.frameId !== null) {
224
+ cancelAnimationFrame(this.frameId);
225
+ this.frameId = null;
226
+ }
227
+ }
228
+ setPosition(position) {
229
+ this.current = position;
230
+ this.onPosition(position);
231
+ }
232
+ }
233
+
101
234
  class ZoomFallbackBoundary extends React.Component {
102
235
  constructor(props) {
103
236
  super(props);
@@ -117,46 +250,6 @@ class ZoomFallbackBoundary extends React.Component {
117
250
  }
118
251
  }
119
252
 
120
- const applyMouseMove = (pageX, pageY, zoomContextRef, setLeft, setTop) => {
121
- const { left, top } = calculateDragPosition(pageX, pageY, zoomContextRef.current.offsets);
122
- const bounds = { minLeft: 0, maxLeft: zoomContextRef.current.bounds.width, minTop: 0, maxTop: zoomContextRef.current.bounds.height };
123
- const clamped = clampToBounds(left, top, bounds);
124
- setLeft(clamped.left * -zoomContextRef.current.ratios.x);
125
- setTop(clamped.top * -zoomContextRef.current.ratios.y);
126
- };
127
- const initializeFollowZoomPosition = (pageX, pageY, container, zoomContextRef, setLeft, setTop) => {
128
- // SSR check: only run if window and container are available
129
- if (typeof window === 'undefined' || !container) {
130
- zoomContextRef.current.bounds = { left: 0, top: 0, width: 0, height: 0 };
131
- zoomContextRef.current.offsets = { x: 0, y: 0 };
132
- setLeft(0);
133
- setTop(0);
134
- return;
135
- }
136
- const bounds = getBounds(container);
137
- zoomContextRef.current.bounds = bounds;
138
- const offsets = getOffsets(window.pageXOffset, window.pageYOffset, -bounds.left, -bounds.top);
139
- zoomContextRef.current.offsets = offsets;
140
- applyMouseMove(pageX, pageY, zoomContextRef, setLeft, setTop);
141
- };
142
- function applyDragMove(x, y, zoomContextRef, setLeft, setTop) {
143
- // This is setting up the animation
144
- const now = Date.now();
145
- zoomContextRef.current.prevDragCoords = zoomContextRef.current.lastDragCoords;
146
- zoomContextRef.current.lastDragCoords = { x, y, time: now };
147
- // Calculate new position using the stored offset
148
- const { left: newLeft, top: newTop } = calculateDragPosition(x, y, zoomContextRef.current.dragStartCoords);
149
- // Clamp to bounds
150
- const { width, height } = zoomContextRef.current.bounds;
151
- const maxLeft = 0;
152
- const minLeft = width * -zoomContextRef.current.ratios.x;
153
- const maxTop = 0;
154
- const minTop = height * -zoomContextRef.current.ratios.y;
155
- const clamped = clampToBounds(newLeft, newTop, { minLeft, maxLeft, minTop, maxTop });
156
- setLeft(clamped.left);
157
- setTop(clamped.top);
158
- }
159
-
160
253
  const CloseIcon = ({ className = 'c-zoom-close-button-icon' }) => (jsxRuntime.jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', className: className, viewBox: '0 0 24 24', fill: 'none', children: jsxRuntime.jsx("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z', fill: '#000' }) }));
161
254
  const FallbackImage = ({ className = 'c-fp-fallback-image' }) => (jsxRuntime.jsxs("svg", { className: className, viewBox: '0 0 2153 1548', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', children: [jsxRuntime.jsx("rect", { width: '100%', height: '100%', fill: 'white' }), jsxRuntime.jsx("path", { d: 'M762 504.5H1392C1425.97 504.5 1453.5 532.034 1453.5 566V982C1453.5 1015.97 1425.97 1043.5 1392 1043.5H762C728.034 1043.5 700.5 1015.97 700.5 982V566C700.5 532.034 728.034 504.5 762 504.5Z', fill: '#EBEEF0', stroke: '#8495A2', strokeWidth: '25' }), jsxRuntime.jsx("path", { d: 'M901.252 812.329C880.253 832.829 710.25 1012.23 707.251 1014.33C704.252 1016.43 728.751 1038.83 745.252 1038.83C761.752 1038.83 1381.75 1039.33 1388.25 1038.83C1394.75 1038.33 1443.75 1036.33 1445.75 981.832C1447.75 927.332 1445.75 946.332 1445.75 946.332C1445.75 946.332 1243.75 723.83 1225.75 705.829C1207.75 687.827 1194.25 681.832 1170.25 705.829C1146.25 729.826 1012.47 866.329 1012.47 866.329C1012.47 866.329 976.253 827.329 957.752 808.829C939.252 790.329 922.252 791.829 901.252 812.329Z', fill: '#CBD4DB' }), jsxRuntime.jsx("path", { d: 'M1056.25 912.329L1012.47 866.329M1012.47 866.329C1012.47 866.329 976.253 827.329 957.752 808.829C939.252 790.329 922.252 791.829 901.252 812.329C880.253 832.829 710.25 1012.23 707.251 1014.33C704.252 1016.43 728.751 1038.83 745.252 1038.83C761.752 1038.83 1381.75 1039.33 1388.25 1038.83C1394.75 1038.33 1443.75 1036.33 1445.75 981.832C1447.75 927.332 1445.75 946.332 1445.75 946.332C1445.75 946.332 1243.75 723.83 1225.75 705.829C1207.75 687.827 1194.25 681.832 1170.25 705.829C1146.25 729.826 1012.47 866.329 1012.47 866.329Z', stroke: '#8595A1', strokeWidth: '25', strokeLinecap: 'round' }), jsxRuntime.jsx("circle", { cx: '891.5', cy: '689.5', r: '60', fill: '#CBD4DA', stroke: '#8496A2', strokeWidth: '25' })] }));
162
255
 
@@ -186,12 +279,12 @@ const BaseImage = ({ src, sources, baseImageStyle = {}, isZoomed, fadeDuration,
186
279
  '--fade-duration': `${isZoomed ? fadeDuration : 0}ms`,
187
280
  ...baseImageStyle,
188
281
  }), [isZoomed, fadeDuration, baseImageStyle]);
189
- const imageClass = [styles['c-point-focus__img'], baseImageClassName].filter(Boolean).join(' ');
282
+ const imageClass = ['c-point-focus__img', baseImageClassName].filter(Boolean).join(' ');
190
283
  const defaultImg = !hasError && src ? (jsxRuntime.jsx("img", { ref: imgRef, alt: alt, src: src, style: imageStyle, onLoad: handleLoad, onError: handleError, className: imageClass, "data-hidden": isZoomed, "data-testid": 'pf-base-image', crossOrigin: 'anonymous' })) : null;
191
284
  const wrappedImage = sources && sources.length > 0 ? (jsxRuntime.jsxs("picture", { style: { width: '100%', height: '100%' }, children: [sources
192
285
  .filter(s => s.srcSet)
193
286
  .map((source, i) => (jsxRuntime.jsx("source", { ...source }, i))), defaultImg] })) : (defaultImg);
194
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [wrappedImage, !disableLoadingFallbacks && isLoading && !hasError && (jsxRuntime.jsx("div", { className: styles['c-point-focus__placeholder'], style: { zIndex: 0 }, "data-testid": 'pf-base-loading', children: loadingPlaceholder ?? jsxRuntime.jsx("span", { className: styles['c-point-focus__loader'] }) })), !disableErrorFallbacks && hasError && (jsxRuntime.jsx("div", { className: styles['c-point-focus__placeholder'], style: { zIndex: 0 }, "data-testid": 'pf-base-error', children: errorPlaceholder ?? jsxRuntime.jsx(FallbackImage, {}) }))] }));
287
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [wrappedImage, !disableLoadingFallbacks && isLoading && !hasError && (jsxRuntime.jsx("div", { className: 'c-point-focus__placeholder', style: { zIndex: 0 }, "data-testid": 'pf-base-loading', children: loadingPlaceholder ?? jsxRuntime.jsx("span", { className: 'c-point-focus__loader' }) })), !disableErrorFallbacks && hasError && (jsxRuntime.jsx("div", { className: 'c-point-focus__placeholder', style: { zIndex: 0 }, "data-testid": 'pf-base-error', children: errorPlaceholder ?? jsxRuntime.jsx(FallbackImage, {}) }))] }));
195
288
  };
196
289
 
197
290
  const ZoomImage = React.forwardRef(({ src, fadeDuration, top, left, isZoomed, onLoad, onDragStart, onDragEnd, onClose, onFadeOut, closeButtonRef, onTouchStart, onTouchEnd, zoomImageClassName, closeButtonClassName, alt, closeButtonAriaLabel, zoomImageAriaLabel, onKeyDown, closeButtonContent, onError, loadingPlaceholder, errorPlaceholder, zoomScale, disableLoadingFallbacks = false, disableErrorFallbacks = false, }, ref) => {
@@ -212,57 +305,42 @@ const ZoomImage = React.forwardRef(({ src, fadeDuration, top, left, isZoomed, on
212
305
  setHasError(true);
213
306
  onError?.();
214
307
  };
215
- const zoomImgClass = [styles['c-point-focus__zoom-img'], zoomImageClassName].filter(Boolean).join(' ');
308
+ const zoomImgClass = ['c-point-focus__zoom-img', zoomImageClassName].filter(Boolean).join(' ');
216
309
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { ref: ref, "data-testid": 'pf-zoom-image', "data-visible": isZoomed, className: zoomImgClass, style: {
217
310
  transform: `translate(${left}px, ${top}px) scale(${zoomScale})`,
218
311
  transformOrigin: 'top left',
219
312
  transition: `opacity ${fadeDuration}ms linear, visibility ${fadeDuration}ms linear`,
220
- }, src: src, onLoad: handleLoad, onError: handleError, onMouseDown: onDragStart, onMouseUp: onDragEnd, onTouchStart: onTouchStart, onTouchEnd: onTouchEnd, onTransitionEnd: onFadeOut, draggable: false, alt: `${alt} zoomed`, "aria-label": zoomImageAriaLabel, onKeyDown: onKeyDown, tabIndex: 0 }), !disableErrorFallbacks && hasError && isZoomed && (jsxRuntime.jsx("div", { className: styles['c-point-focus__placeholder'], "data-testid": 'pf-zoom-error', children: errorPlaceholder ?? jsxRuntime.jsx(FallbackImage, {}) })), !disableLoadingFallbacks && isLoading && !hasError && isZoomed && (jsxRuntime.jsx("div", { className: styles['c-point-focus__placeholder'], "data-testid": 'pf-zoom-loading', children: loadingPlaceholder ?? jsxRuntime.jsx("span", { className: styles['c-point-focus__loader'] }) })), onClose && (jsxRuntime.jsx("button", { type: 'button', ref: closeButtonRef, title: 'Close Zoom', "data-testid": 'pf-close-button', "aria-label": closeButtonAriaLabel ?? 'Zoom out', "data-visible": isZoomed, "data-action-type": 'close', className: closeButtonClassName || styles['c-point-focus__button'], style: {
313
+ }, src: src, onLoad: handleLoad, onError: handleError, onMouseDown: onDragStart, onMouseUp: onDragEnd, onTouchStart: onTouchStart, onTouchEnd: onTouchEnd, onTransitionEnd: onFadeOut, draggable: false, alt: `${alt} zoomed`, "aria-label": zoomImageAriaLabel, onKeyDown: onKeyDown, tabIndex: 0 }), !disableErrorFallbacks && hasError && isZoomed && (jsxRuntime.jsx("div", { className: 'c-point-focus__placeholder', "data-testid": 'pf-zoom-error', children: errorPlaceholder ?? jsxRuntime.jsx(FallbackImage, {}) })), !disableLoadingFallbacks && isLoading && !hasError && isZoomed && (jsxRuntime.jsx("div", { className: 'c-point-focus__placeholder', "data-testid": 'pf-zoom-loading', children: loadingPlaceholder ?? jsxRuntime.jsx("span", { className: 'c-point-focus__loader' }) })), onClose && (jsxRuntime.jsx("button", { type: 'button', ref: closeButtonRef, title: 'Close Zoom', "data-testid": 'pf-close-button', "aria-label": closeButtonAriaLabel ?? 'Zoom out', "data-visible": isZoomed, "data-action-type": 'close', className: closeButtonClassName || 'c-point-focus__button', style: {
221
314
  transition: `opacity ${fadeDuration}ms linear, visibility ${fadeDuration}ms linear`,
222
315
  }, onClick: () => onClose?.('click'), onKeyDown: onKeyDown, children: closeButtonContent ?? jsxRuntime.jsx(CloseIcon, {}) }))] }));
223
316
  });
224
317
  ZoomImage.displayName = 'ZoomImage';
225
318
 
226
- function startInertia({ initialLeft, initialTop, velocity, setLeft, setTop, bounds, friction = 0.95, minVelocity = 10, onEnd, contextRef, }) {
227
- let left = initialLeft;
228
- let top = initialTop;
229
- let vx = velocity.vx;
230
- let vy = velocity.vy;
231
- function step() {
232
- vx *= friction;
233
- vy *= friction;
234
- left += vx * (1 / 60);
235
- top += vy * (1 / 60);
236
- const clamped = clampToBounds(left, top, bounds);
237
- setLeft(clamped.left);
238
- setTop(clamped.top);
239
- if (Math.abs(vx) > minVelocity || Math.abs(vy) > minVelocity) {
240
- contextRef.current.rafId = requestAnimationFrame(step); // 👈 Store rafId
241
- }
242
- else {
243
- contextRef.current.rafId = null;
244
- setLeft(clamped.left);
245
- setTop(clamped.top);
246
- onEnd?.();
247
- }
248
- }
249
- contextRef.current.rafId = requestAnimationFrame(step);
250
- }
251
-
319
+ const createSession = () => ({ onLoadCallback: null, wasDragging: false, lastMoveEvent: null, moveFrameId: null });
252
320
  const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, zoomPreload, fadeDuration = 150, moveType = 'follow', zoomType = 'click', baseImageStyle, hideCloseButton, containerClassName, baseImageClassName, zoomImageClassName, closeButtonClassName, onMouseEnter, onZoomedMouseMove, onMouseLeave, onClickImage, onZoom, onClose, afterZoomImgLoaded, afterZoomOut, onBaseImageError, onZoomImageError, onDragStart, onDragEnd, alt, containerAriaLabel, closeButtonAriaLabel, zoomImageAriaLabel, tabIndex = 0, closeButtonContent, overlay, disableDrag, disableInertia, loadingPlaceholder, errorPlaceholder, clickToZoomOut = false, externalZoomState, setExternalZoomState, disableMobile, disableLoadingFallbacks, disableErrorFallbacks, }) => {
253
321
  const containerRef = React.useRef(null);
254
322
  const closeButtonRef = React.useRef(null);
255
323
  const zoomedImgRef = React.useRef(null);
256
- const zoomContextRef = React.useRef(getDefaults());
324
+ const sessionRef = React.useRef(createSession());
325
+ const engineRef = React.useRef(null);
326
+ if (!engineRef.current) {
327
+ engineRef.current = new ZoomEngine({
328
+ onPosition: ({ left, top }) => {
329
+ if (zoomedImgRef.current)
330
+ zoomedImgRef.current.style.transform = `translate(${left}px, ${top}px) scale(${safeZoomScaleRef.current})`;
331
+ },
332
+ });
333
+ }
334
+ const engine = engineRef.current;
257
335
  const isControlled = externalZoomState !== undefined;
258
336
  const [internalZoom, setInternalZoom] = React.useState(false);
259
337
  const isZoomed = isControlled ? externalZoomState : internalZoom;
260
338
  const [isActive, setIsActive] = React.useState(zoomPreload);
261
339
  const [isDragging, setIsDragging] = React.useState(false);
262
340
  const [isFading, setIsFading] = React.useState(false);
263
- const [left, setLeft] = React.useState(0);
264
- const [top, setTop] = React.useState(0);
265
- const safeZoomScale = Math.max(1, Math.min(zoomScale, 5));
341
+ const safeZoomScale = clampZoomScale(zoomScale);
342
+ const safeZoomScaleRef = React.useRef(safeZoomScale);
343
+ safeZoomScaleRef.current = safeZoomScale;
266
344
  const updateZoomState = (val) => {
267
345
  if (isControlled) {
268
346
  setExternalZoomState?.(val);
@@ -273,7 +351,7 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
273
351
  };
274
352
  const zoomIn = (pageX, pageY, method) => {
275
353
  updateZoomState(true);
276
- initializeFollowZoomPosition(pageX, pageY, containerRef.current, zoomContextRef, setLeft, setTop);
354
+ engine.startFollow(pageX, pageY, containerRef.current);
277
355
  onZoom?.({ at: { x: pageX, y: pageY }, method: method });
278
356
  setTimeout(() => {
279
357
  closeButtonRef.current?.focus();
@@ -283,98 +361,45 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
283
361
  if (!zoomPreload) {
284
362
  setIsFading(true);
285
363
  }
286
- zoomContextRef.current.onLoadCallback = null;
287
- zoomContextRef.current.wasDragging = false;
288
- zoomContextRef.current.dragStartCoords = { x: 0, y: 0 };
289
- zoomContextRef.current.velocity = null;
290
- zoomContextRef.current.prevDragCoords = null;
291
- zoomContextRef.current.lastDragCoords = null;
292
- setLeft(0);
293
- setTop(0);
364
+ sessionRef.current.onLoadCallback = null;
365
+ sessionRef.current.wasDragging = false;
366
+ engine.reset();
294
367
  updateZoomState(false);
295
368
  };
296
369
  const handleDragStart = React.useCallback((e) => {
297
370
  if (!isZoomed || disableDrag || (disableMobile && isTouchEvent(e)))
298
371
  return;
299
- if (zoomContextRef.current.rafId != null) {
300
- cancelAnimationFrame(zoomContextRef.current.rafId);
301
- zoomContextRef.current.rafId = null;
302
- }
303
372
  const { x, y } = getPageCoords(e);
373
+ engine.beginDrag(x, y);
304
374
  setIsDragging(true);
305
- zoomContextRef.current.dragStartCoords = getOffsets(x, y, left, top);
306
375
  onDragStart?.({
307
376
  start: { x, y },
308
377
  source: isTouchEvent(e) ? 'touch' : 'mouse',
309
378
  });
310
- }, [isZoomed, disableDrag, disableMobile, left, top, onDragStart]);
379
+ }, [isZoomed, disableDrag, disableMobile, engine, onDragStart]);
311
380
  const handleDragMove = React.useCallback((e) => {
312
- if (!isDragging)
381
+ if (!engine.isDragging)
313
382
  return;
314
383
  const { x, y } = getPageCoords(e);
315
- applyDragMove(x, y, zoomContextRef, setLeft, setTop);
384
+ engine.moveDrag(x, y);
316
385
  if ('touches' in e)
317
386
  e.preventDefault?.();
318
- }, [isDragging, setLeft, setTop]);
387
+ }, [engine]);
319
388
  const handleDragEnd = React.useCallback(() => {
389
+ const result = engine.endDrag(!disableInertia);
390
+ if (!result)
391
+ return;
320
392
  setIsDragging(false);
321
- zoomContextRef.current.dragStartCoords = { x: 0, y: 0 };
322
- // Animation on end
323
- // Calculate velocity
324
- const last = zoomContextRef.current.lastDragCoords;
325
- const prev = zoomContextRef.current.prevDragCoords;
326
- let vx = 0, vy = 0;
327
- if (last && prev) {
328
- const dt = (last.time - prev.time) / 1000;
329
- if (dt > 0) {
330
- vx = (last.x - prev.x) / dt;
331
- vy = (last.y - prev.y) / dt;
332
- }
333
- }
334
- zoomContextRef.current.velocity = { vx, vy };
335
- // Calculate bounds
336
- const { width, height } = zoomContextRef.current.bounds;
337
- const maxLeft = 0;
338
- const minLeft = width * -zoomContextRef.current.ratios.x;
339
- const maxTop = 0;
340
- const minTop = height * -zoomContextRef.current.ratios.y;
341
- if (!disableInertia) {
342
- startInertia({
343
- initialLeft: left,
344
- initialTop: top,
345
- velocity: { vx, vy },
346
- setLeft,
347
- setTop,
348
- bounds: { minLeft, maxLeft, minTop, maxTop },
349
- friction: 0.95,
350
- minVelocity: 10,
351
- onEnd: () => {
352
- // Optionally, snap to bounds or do something else
353
- },
354
- contextRef: zoomContextRef,
355
- });
356
- }
357
- onDragEnd?.({
358
- velocity: { vx, vy },
359
- final: { x: left, y: top },
360
- });
361
- }, [disableInertia, left, top, setLeft, setTop, onDragEnd]);
393
+ if (result.moved)
394
+ sessionRef.current.wasDragging = true;
395
+ onDragEnd?.({ velocity: result.velocity, final: result.final });
396
+ }, [engine, disableInertia, onDragEnd]);
362
397
  const applyImageLoad = (el) => {
363
- const naturalDimensions = {
364
- width: el.naturalWidth,
365
- height: el.naturalHeight,
366
- };
367
- const bounds = getBounds(containerRef.current);
368
398
  zoomedImgRef.current = el;
369
- zoomContextRef.current.scaledDimensions = {
370
- width: naturalDimensions.width * safeZoomScale,
371
- height: naturalDimensions.height * safeZoomScale,
372
- };
373
- zoomContextRef.current.bounds = bounds;
374
- zoomContextRef.current.ratios = getRatios(bounds, naturalDimensions, safeZoomScale);
375
- if (zoomContextRef.current.onLoadCallback) {
376
- zoomContextRef.current.onLoadCallback();
377
- zoomContextRef.current.onLoadCallback = null;
399
+ engine.measure(containerRef.current, { width: el.naturalWidth, height: el.naturalHeight }, safeZoomScale);
400
+ if (sessionRef.current.onLoadCallback) {
401
+ sessionRef.current.onLoadCallback();
402
+ sessionRef.current.onLoadCallback = null;
378
403
  }
379
404
  };
380
405
  const handleLoad = React.useCallback((e) => {
@@ -390,8 +415,8 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
390
415
  return;
391
416
  const { x, y } = getPageCoords(e);
392
417
  onClickImage?.({ x, y, source: isTouchEvent(e) ? 'touch' : 'mouse' });
393
- if (zoomContextRef.current.wasDragging) {
394
- zoomContextRef.current.wasDragging = false;
418
+ if (sessionRef.current.wasDragging) {
419
+ sessionRef.current.wasDragging = false;
395
420
  return;
396
421
  }
397
422
  if (isZoomed) {
@@ -405,7 +430,7 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
405
430
  zoomIn(x, y, method);
406
431
  }
407
432
  else {
408
- zoomContextRef.current.onLoadCallback = () => zoomIn(x, y, method);
433
+ sessionRef.current.onLoadCallback = () => zoomIn(x, y, method);
409
434
  }
410
435
  }, [disableMobile, isTouchEvent, getPageCoords, onClickImage, isZoomed, clickToZoomOut, handleClose, applyImageLoad, zoomIn]);
411
436
  const handleKeyDown = React.useCallback((e) => {
@@ -426,14 +451,14 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
426
451
  }
427
452
  }, [isZoomed, handleClose]);
428
453
  const throttledZoomedMouseMove = React.useCallback((x, y, bounds) => {
429
- zoomContextRef.current.lastMoveEvent = { x, y, bounds };
430
- if (zoomContextRef.current.rafId == null) {
431
- zoomContextRef.current.rafId = window.requestAnimationFrame(() => {
432
- const evt = zoomContextRef.current.lastMoveEvent;
454
+ sessionRef.current.lastMoveEvent = { x, y, bounds };
455
+ if (sessionRef.current.moveFrameId == null) {
456
+ sessionRef.current.moveFrameId = window.requestAnimationFrame(() => {
457
+ const evt = sessionRef.current.lastMoveEvent;
433
458
  if (evt && onZoomedMouseMove) {
434
459
  onZoomedMouseMove(evt);
435
460
  }
436
- zoomContextRef.current.rafId = null;
461
+ sessionRef.current.moveFrameId = null;
437
462
  });
438
463
  }
439
464
  }, [onZoomedMouseMove]);
@@ -448,13 +473,10 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
448
473
  const handleMouseMove = React.useCallback((e) => {
449
474
  if (moveType === 'follow' && isZoomed) {
450
475
  const { x, y } = getPageCoords(e);
451
- const bounds = zoomContextRef.current.bounds;
452
- if (!bounds || typeof bounds.left !== 'number')
453
- return;
454
- throttledZoomedMouseMove(x, y, zoomContextRef.current.bounds);
455
- applyMouseMove(x, y, zoomContextRef, setLeft, setTop);
476
+ throttledZoomedMouseMove(x, y, engine.containerBounds);
477
+ engine.follow(x, y);
456
478
  }
457
- }, [moveType, isZoomed, throttledZoomedMouseMove, setLeft, setTop]);
479
+ }, [moveType, isZoomed, throttledZoomedMouseMove, engine]);
458
480
  const handleMouseLeave = React.useCallback((e) => {
459
481
  onMouseLeave?.({ source: isTouchEvent(e) ? 'touch' : 'mouse' });
460
482
  handleClose('hover');
@@ -463,7 +485,7 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
463
485
  if (noTransition || (e && 'propertyName' in e && e.propertyName === 'opacity' && containerRef?.current?.contains(e.target))) {
464
486
  if (!zoomPreload) {
465
487
  zoomedImgRef.current = null;
466
- zoomContextRef.current = getDefaults();
488
+ sessionRef.current = createSession();
467
489
  setIsActive(false);
468
490
  }
469
491
  setIsFading(false);
@@ -471,14 +493,14 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
471
493
  }
472
494
  }, [zoomPreload, setIsActive, setIsFading, afterZoomOut]);
473
495
  React.useEffect(() => {
474
- zoomContextRef.current = getDefaults();
475
496
  return () => {
476
- if (zoomContextRef.current.rafId != null) {
477
- cancelAnimationFrame(zoomContextRef.current.rafId);
478
- zoomContextRef.current.rafId = null;
497
+ engine.destroy();
498
+ if (sessionRef.current.moveFrameId != null) {
499
+ cancelAnimationFrame(sessionRef.current.moveFrameId);
500
+ sessionRef.current.moveFrameId = null;
479
501
  }
480
502
  };
481
- }, []);
503
+ }, [engine]);
482
504
  React.useEffect(() => {
483
505
  if (isDragging && !disableDrag) {
484
506
  window.addEventListener('mousemove', handleDragMove);
@@ -492,12 +514,12 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
492
514
  window.removeEventListener('touchend', handleDragEnd);
493
515
  };
494
516
  }
495
- }, [isDragging]);
517
+ }, [isDragging, disableDrag, handleDragMove, handleDragEnd]);
496
518
  const zoomImageProps = {
497
519
  src: zoomSrc || src,
498
520
  fadeDuration: fadeDuration,
499
- top,
500
- left,
521
+ top: engine.position.top,
522
+ left: engine.position.left,
501
523
  isZoomed,
502
524
  onLoad: handleLoad,
503
525
  onError: onZoomImageError,
@@ -521,12 +543,12 @@ const ImageMagnifier = ({ src, sources, width, height, zoomSrc, zoomScale = 1, z
521
543
  disableLoadingFallbacks: disableLoadingFallbacks,
522
544
  disableErrorFallbacks: disableErrorFallbacks,
523
545
  };
524
- const containerClass = [styles['c-point-focus'], containerClassName].filter(Boolean).join(' ');
546
+ const containerClass = ['c-point-focus', containerClassName].filter(Boolean).join(' ');
525
547
  return (jsxRuntime.jsxs("figure", { role: 'group', ref: containerRef, tabIndex: tabIndex, "data-movetype": moveType, "data-testid": 'pf-image-magnifier-container', "aria-label": containerAriaLabel ?? 'Zoomable image', className: containerClass, style: { width: width, height: height }, onClick: e => handleClick(e, 'hover'), onTouchStart: e => {
526
548
  if (disableMobile) {
527
549
  e.preventDefault();
528
550
  }
529
- }, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, onMouseMove: isZoomed ? handleMouseMove : undefined, onMouseLeave: handleMouseLeave, children: [jsxRuntime.jsx(BaseImage, { src: src, alt: alt, sources: sources, width: width, height: height, baseImageStyle: baseImageStyle, baseImageClassName: baseImageClassName, fadeDuration: fadeDuration, isZoomed: isZoomed, onError: onBaseImageError, loadingPlaceholder: loadingPlaceholder, errorPlaceholder: errorPlaceholder, disableLoadingFallbacks: disableLoadingFallbacks, disableErrorFallbacks: disableErrorFallbacks }), isActive && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [overlay && (jsxRuntime.jsx("div", { className: styles['c-point-focus__overlay'], "data-testid": 'pf-overlay', children: overlay })), jsxRuntime.jsx(ZoomFallbackBoundary, { fallback: errorPlaceholder ?? jsxRuntime.jsx(FallbackImage, {}), children: jsxRuntime.jsx(ZoomImage, { ref: zoomedImgRef, ...zoomImageProps }, isZoomed && clickToZoomOut ? 'zoomed' : 'unzoomed') })] }))] }));
551
+ }, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, onMouseMove: isZoomed ? handleMouseMove : undefined, onMouseLeave: handleMouseLeave, children: [jsxRuntime.jsx(BaseImage, { src: src, alt: alt, sources: sources, width: width, height: height, baseImageStyle: baseImageStyle, baseImageClassName: baseImageClassName, fadeDuration: fadeDuration, isZoomed: isZoomed, onError: onBaseImageError, loadingPlaceholder: loadingPlaceholder, errorPlaceholder: errorPlaceholder, disableLoadingFallbacks: disableLoadingFallbacks, disableErrorFallbacks: disableErrorFallbacks }), isActive && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [overlay && (jsxRuntime.jsx("div", { className: 'c-point-focus__overlay', "data-testid": 'pf-overlay', children: overlay })), jsxRuntime.jsx(ZoomFallbackBoundary, { fallback: errorPlaceholder ?? jsxRuntime.jsx(FallbackImage, {}), children: jsxRuntime.jsx(ZoomImage, { ref: zoomedImgRef, ...zoomImageProps }, isZoomed && clickToZoomOut ? 'zoomed' : 'unzoomed') })] }))] }));
530
552
  };
531
553
 
532
554
  module.exports = ImageMagnifier;