@cntrl-site/components 1.0.119 → 1.0.120-alpha.1

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/sources.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ChroniclesComponent-Bp8Zmj26.js"),e=`import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ChroniclesComponent-CdhGfFOq.js"),e=`import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
2
2
  import { CommonComponentProps } from '../props';
3
3
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
4
4
  import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
@@ -11067,7 +11067,7 @@ export function Hive({
11067
11067
  </>
11068
11068
  );
11069
11069
  }
11070
- `,c=`import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11070
+ `,d=`import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11071
11071
  import { createPortal } from 'react-dom';
11072
11072
  import { CommonComponentProps } from '../props';
11073
11073
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -11870,7 +11870,7 @@ export type LightboxJournalSettings = {
11870
11870
  closeIconColor: string;
11871
11871
  closeIconHoverColor: string;
11872
11872
  };
11873
- `,d=`import { useEffect, useRef, useState, type MouseEvent } from 'react';
11873
+ `,c=`import { useEffect, useRef, useState, type MouseEvent } from 'react';
11874
11874
  import { createPortal } from 'react-dom';
11875
11875
  import { CommonComponentProps } from '../props';
11876
11876
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -22598,7 +22598,6 @@ type Slider20Item = {
22598
22598
  image: {
22599
22599
  assetId: string;
22600
22600
  name?: string;
22601
- objectFit?: 'cover' | 'contain';
22602
22601
  };
22603
22602
  imageCaption: any[];
22604
22603
  };
@@ -22620,6 +22619,7 @@ type Slider20Settings = {
22620
22619
  trigger?: Slider20Trigger;
22621
22620
  direction?: Slider20Direction;
22622
22621
  transition?: Slider20Transition;
22622
+ transitionSpeed?: number;
22623
22623
  nav?: Slider20Nav;
22624
22624
  navSize?: Slider20NavSize;
22625
22625
  navUnit?: number;
@@ -22650,6 +22650,7 @@ type Slider20Settings = {
22650
22650
  fontVariant?: 'normal' | 'small-caps';
22651
22651
  };
22652
22652
  captionMarginTop?: number;
22653
+ imageCorners?: number;
22653
22654
  };
22654
22655
 
22655
22656
  type Slider20Props = {
@@ -22661,6 +22662,7 @@ type Slider20Props = {
22661
22662
  } & CommonComponentProps;
22662
22663
 
22663
22664
  type Offset = { x: number; y: number };
22665
+ type TransitionLayer = { index: number; key: number };
22664
22666
  type Point = { x: number; y: number };
22665
22667
  type LocalAxes = { ex: Point; ey: Point; det: number };
22666
22668
 
@@ -22678,9 +22680,11 @@ type DragState = {
22678
22680
  };
22679
22681
 
22680
22682
  const TRANSITION_DURATION_MS = 500;
22683
+ const DEFAULT_TRANSITION_SPEED = 1;
22681
22684
  const TRANSITION_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
22682
22685
  const TRANSITION_BACKGROUND_COLOR: string | null = null;
22683
22686
  const DOT_ANIMATION_MS = 300;
22687
+ const MAX_TRANSITION_LAYERS = 40;
22684
22688
  const DRAG_START_THRESHOLD_PX = 5;
22685
22689
  const DRAG_DISTANCE_RATIO = 0.15;
22686
22690
  const DRAG_FLICK_VELOCITY = 0.4;
@@ -22782,23 +22786,24 @@ function wrapIndex(index: number, count: number): number {
22782
22786
  return ((index % count) + count) % count;
22783
22787
  }
22784
22788
 
22785
- function advanceTrackPosition(
22786
- prev: number,
22787
- step: 1 | -1,
22788
- count: number,
22789
- hasClones: boolean,
22790
- ): { position: number; hitBoundary: boolean } {
22791
- if (!hasClones) {
22792
- return { position: wrapIndex(prev + step, count), hitBoundary: false };
22793
- }
22794
- const next = prev + step;
22795
- if (next >= 0 && next <= count + 1) {
22796
- return { position: next, hitBoundary: false };
22797
- }
22798
- return {
22799
- position: step > 0 ? count + 1 : 0,
22800
- hitBoundary: true,
22801
- };
22789
+ // Slide mode renders the items three times; shifting the track by one copy is invisible.
22790
+ const TRACK_COPIES = 3;
22791
+
22792
+ function getTrackTranslate(position: number, offsetPx: number, isHorizontal: boolean): string {
22793
+ return isHorizontal
22794
+ ? \`translate3d(calc(\${-position * 100}% + \${offsetPx}px), 0, 0)\`
22795
+ : \`translate3d(0, calc(\${-position * 100}% + \${offsetPx}px), 0)\`;
22796
+ }
22797
+
22798
+ // Shift (a multiple of count) that moves a position into the middle copy.
22799
+ function getMiddleCopyShift(position: number, count: number): number {
22800
+ return (Math.floor(position / count) - 1) * count;
22801
+ }
22802
+
22803
+ // Untransformed, unrounded size of one slide (offsetWidth rounds, the canvas zoom scales rects).
22804
+ function readSlideSizePx(element: HTMLElement, isHorizontal: boolean): number {
22805
+ const style = window.getComputedStyle(element);
22806
+ return parseFloat(isHorizontal ? style.width : style.height) || 0;
22802
22807
  }
22803
22808
 
22804
22809
  function readTrackTranslatePx(element: HTMLElement, isHorizontal: boolean): number {
@@ -22840,7 +22845,13 @@ function toLocalDelta(axes: LocalAxes, dx: number, dy: number): Point {
22840
22845
  };
22841
22846
  }
22842
22847
 
22843
- function getCSS(P: string, isEditor?: boolean): string {
22848
+ // Speed 0..2 maps to 2000ms..125ms on a log scale; speed 1 keeps the base 500ms.
22849
+ function getTransitionDurationMs(speed: number): number {
22850
+ const clamped = Math.min(Math.max(speed, 0), 2);
22851
+ return Math.round(TRANSITION_DURATION_MS * Math.pow(4, 1 - clamped));
22852
+ }
22853
+
22854
+ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): string {
22844
22855
  return \`
22845
22856
  .\${P}-wrapper {
22846
22857
  position: relative;
@@ -22901,6 +22912,8 @@ function getCSS(P: string, isEditor?: boolean): string {
22901
22912
  }
22902
22913
  .\${P}-list-fade {
22903
22914
  display: block;
22915
+ /* Keeps the transition layers' z-index below the arrows, dots and click overlay. */
22916
+ isolation: isolate;
22904
22917
  }
22905
22918
  .\${P}-slide {
22906
22919
  position: relative;
@@ -22913,11 +22926,9 @@ function getCSS(P: string, isEditor?: boolean): string {
22913
22926
  top: 0;
22914
22927
  left: 0;
22915
22928
  opacity: 0;
22916
- transition: opacity \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING};
22917
22929
  }
22918
- .\${P}-list-fade .\${P}-slide.\${P}-is-active {
22930
+ .\${P}-list-fade .\${P}-slide.\${P}-is-layer {
22919
22931
  opacity: 1;
22920
- z-index: 1;
22921
22932
  }
22922
22933
  .\${P}-slider-item {
22923
22934
  width: 100%;
@@ -23092,17 +23103,18 @@ function getCSS(P: string, isEditor?: boolean): string {
23092
23103
  cursor: pointer;
23093
23104
  z-index: 2;
23094
23105
  }
23095
- .\${P}-contain {
23096
- object-fit: contain;
23106
+ .\${P}-transition-fade .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23107
+ animation: \${P}-fade-in \${transitionDurationMs}ms \${TRANSITION_EASING};
23097
23108
  }
23098
- .\${P}-cover {
23099
- object-fit: cover;
23109
+ .\${P}-transition-reveal .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23110
+ animation: \${P}-reveal-horizontal \${transitionDurationMs}ms ease;
23100
23111
  }
23101
- .\${P}-transition-reveal .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23102
- animation: \${P}-reveal-horizontal \${TRANSITION_DURATION_MS}ms ease;
23112
+ .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23113
+ animation: \${P}-reveal-vertical \${transitionDurationMs}ms ease;
23103
23114
  }
23104
- .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23105
- animation: \${P}-reveal-vertical \${TRANSITION_DURATION_MS}ms ease;
23115
+ @keyframes \${P}-fade-in {
23116
+ from { opacity: 0; }
23117
+ to { opacity: 1; }
23106
23118
  }
23107
23119
  @keyframes \${P}-reveal-horizontal {
23108
23120
  from { clip-path: inset(0 100% 0 0); }
@@ -23125,6 +23137,8 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23125
23137
  const autoPlayIntervalS = trigger.value ?? DEFAULT_TRIGGER.value;
23126
23138
  const direction: Slider20Direction = settings?.direction ?? 'horizontal';
23127
23139
  const transition: Slider20Transition = settings?.transition ?? 'slide';
23140
+ const transitionSpeed = typeof settings?.transitionSpeed === 'number' ? settings.transitionSpeed : DEFAULT_TRANSITION_SPEED;
23141
+ const transitionDurationMs = getTransitionDurationMs(transitionSpeed);
23128
23142
  const nav: Slider20Nav = settings?.nav ?? 'classic';
23129
23143
  const navSize: Slider20NavSize = settings?.navSize ?? 'm';
23130
23144
  const navSizeValues = NAV_SIZES[navSize];
@@ -23142,12 +23156,21 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23142
23156
  const navBackgroundColor = settings?.navBackgroundColor ?? PAGINATION.colors.background;
23143
23157
  const linkColor = settings?.linkColor ?? IMAGE_CAPTION.linkColor;
23144
23158
  const captionMarginTop = typeof settings?.captionMarginTop === 'number' ? settings.captionMarginTop : 0;
23159
+ const imageCorners = typeof settings?.imageCorners === 'number' ? settings.imageCorners : 0;
23160
+ // Rounding the track (not each image) keeps the corners steady while slides move under it.
23161
+ // isolation makes Safari clip the transformed list to the radius.
23162
+ const trackRadiusStyle: React.CSSProperties | undefined = imageCorners > 0
23163
+ ? { borderRadius: scalingValue(imageCorners, isEditor), isolation: 'isolate' }
23164
+ : undefined;
23145
23165
  const isHorizontal = direction === 'horizontal';
23146
23166
  const isClickTrigger = triggerType === 'click';
23147
23167
  const isDragTrigger = triggerType === 'drag';
23148
23168
  const isAutoPlaying = triggerType === 'auto' && (!isEditor || Boolean(isPreviewMode));
23149
23169
  const pauseAutoOnHover = !isEditor;
23150
23170
  const isSlideTransition = transition === 'slide';
23171
+ const isReveal = transition === 'reveal';
23172
+ // Fade and reveal draw each new slide as a layer over the previous ones.
23173
+ const isLayered = !isSlideTransition;
23151
23174
  const showClassicNav = nav === 'classic';
23152
23175
  const showControls = controlsShow !== 'never' && controlsMaxWidth > 0;
23153
23176
  const isControlsOnHover = controlsShow === 'on hover';
@@ -23160,7 +23183,36 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23160
23183
 
23161
23184
  const hasClones = isSlideTransition && count > 1;
23162
23185
  const [activeIndex, setActiveIndex] = useState(0);
23163
- const [trackPosition, setTrackPosition] = useState(hasClones ? 1 : 0);
23186
+ // Layers stack bottom to top: each new slide fades or reveals over the ones still animating,
23187
+ // which keep their own animation. The same slide can sit in the stack more than once.
23188
+ const [transitionLayers, setTransitionLayers] = useState<TransitionLayer[]>([{ index: activeIndex, key: 0 }]);
23189
+ const topLayer = transitionLayers[transitionLayers.length - 1];
23190
+ if (isLayered && topLayer.index !== activeIndex) {
23191
+ // Over the limit, drop the oldest layer still animating, never the fully shown bottom one.
23192
+ const kept = transitionLayers.length >= MAX_TRANSITION_LAYERS
23193
+ ? [transitionLayers[0], ...transitionLayers.slice(2)]
23194
+ : transitionLayers;
23195
+ setTransitionLayers([...kept, { index: activeIndex, key: topLayer.key + 1 }]);
23196
+ }
23197
+ const handleLayerEnd = (key: number) => {
23198
+ // A fully shown layer covers everything under it, so those layers are dropped.
23199
+ setTransitionLayers((layers) => {
23200
+ const position = layers.findIndex((layer) => layer.key === key);
23201
+ return position > 0 ? layers.slice(position) : layers;
23202
+ });
23203
+ };
23204
+ const renderSlideItem = (item: Slider20Item | undefined) => item && (
23205
+ <div className={\`\${P}-slider-item\`}>
23206
+ <div className={\`\${P}-img-wrapper\`}>
23207
+ <img
23208
+ className={\`\${P}-slider-image\`}
23209
+ src={item.image.assetId} alt={item.image.name ?? ''}
23210
+ draggable={false}
23211
+ />
23212
+ </div>
23213
+ </div>
23214
+ );
23215
+ const [trackPosition, setTrackPosition] = useState(hasClones ? count : 0);
23164
23216
  const [isMoving, setIsMoving] = useState(false);
23165
23217
  const [skipTransition, setSkipTransition] = useState(false);
23166
23218
  const [isDragging, setIsDragging] = useState(false);
@@ -23170,8 +23222,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23170
23222
  const isMovingRef = useRef(false);
23171
23223
  const trackPositionRef = useRef(trackPosition);
23172
23224
  trackPositionRef.current = trackPosition;
23173
- const pendingAnimatedPositionRef = useRef<number | null>(null);
23174
- const pendingStepsRef = useRef(0);
23175
23225
  const trackRef = useRef<HTMLDivElement | null>(null);
23176
23226
  const listRef = useRef<HTMLDivElement | null>(null);
23177
23227
  const dragRef = useRef<DragState | null>(null);
@@ -23182,59 +23232,56 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23182
23232
  setIsMoving(value);
23183
23233
  }, []);
23184
23234
 
23235
+ // Where the track is on screen right now, mid-transition included, in slide units.
23236
+ const readVisualPosition = useCallback((): number => {
23237
+ const list = listRef.current;
23238
+ const size = list ? readSlideSizePx(list, isHorizontal) : 0;
23239
+ if (!list || size <= 0) return trackPositionRef.current;
23240
+ // Rounded so a settled track reads as a whole position.
23241
+ return Math.round((-readTrackTranslatePx(list, isHorizontal) / size) * 1000) / 1000;
23242
+ }, [isHorizontal]);
23243
+
23244
+ // Moves the track to \`target\` from wherever it is now. When the visual position is outside
23245
+ // the middle copy, it is first teleported by a whole copy (no visible change), so rapid
23246
+ // navigation never runs off the rendered slides and never snaps mid-animation.
23247
+ const moveTrack = useCallback((getTarget: (visual: number, shift: number) => number) => {
23248
+ const visual = readVisualPosition();
23249
+ const shift = getMiddleCopyShift(visual, count);
23250
+ const target = getTarget(visual - shift, shift);
23251
+ const list = listRef.current;
23252
+ if (shift !== 0 && list) {
23253
+ const transitionValue = list.style.transition;
23254
+ list.style.transition = 'none';
23255
+ list.style.transform = getTrackTranslate(visual - shift, 0, isHorizontal);
23256
+ void list.offsetWidth;
23257
+ list.style.transition = transitionValue && transitionValue !== 'none'
23258
+ ? transitionValue
23259
+ : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`;
23260
+ list.style.transform = getTrackTranslate(target, 0, isHorizontal);
23261
+ }
23262
+ trackPositionRef.current = target;
23263
+ setActiveIndex(wrapIndex(target, count));
23264
+ setSkipTransition(false);
23265
+ setTrackPosition(target);
23266
+ }, [count, isHorizontal, readVisualPosition, transitionDurationMs]);
23267
+
23185
23268
  const goBySteps = useCallback((steps: number) => {
23186
23269
  if (count < 2 || steps === 0) return;
23187
- const direction = steps > 0 ? 1 : -1;
23188
- const total = Math.abs(steps);
23189
23270
  setAnimateDots(true);
23190
23271
  setMoving(true);
23191
23272
  if (!isSlideTransition) {
23192
23273
  setActiveIndex((prev) => wrapIndex(prev + steps, count));
23193
23274
  return;
23194
23275
  }
23195
-
23196
- let position = trackPositionRef.current;
23197
- const isOnClone = hasClones && (position === 0 || position === count + 1);
23198
- const cloneSnapPosition = isOnClone ? activeIndex + 1 : null;
23199
-
23200
- if (isOnClone) {
23201
- position = activeIndex + 1;
23202
- }
23203
-
23204
- let remaining = total;
23205
- while (remaining > 0) {
23206
- const result = advanceTrackPosition(position, direction, count, hasClones);
23207
- position = result.position;
23208
- remaining -= 1;
23209
- if (result.hitBoundary) {
23210
- pendingStepsRef.current = remaining * direction;
23211
- break;
23212
- }
23213
- }
23214
-
23215
- const appliedSteps = total - remaining;
23216
- if (appliedSteps > 0) {
23217
- setActiveIndex((prev) => wrapIndex(prev + appliedSteps * direction, count));
23218
- }
23219
-
23220
- trackPositionRef.current = position;
23221
-
23222
- if (cloneSnapPosition !== null) {
23223
- trackPositionRef.current = cloneSnapPosition;
23224
- if (position === cloneSnapPosition) {
23225
- setSkipTransition(true);
23226
- setTrackPosition(position);
23227
- return;
23228
- }
23229
- pendingAnimatedPositionRef.current = position;
23230
- setSkipTransition(true);
23231
- setTrackPosition(cloneSnapPosition);
23232
- return;
23233
- }
23234
-
23235
- setSkipTransition(false);
23236
- setTrackPosition(position);
23237
- }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23276
+ moveTrack((visual, shift) => {
23277
+ // Continue from the previous target so quick clicks add up, but never get more than
23278
+ // count - 1 slides away from what is on screen, which keeps the target inside the copies.
23279
+ const previousTarget = trackPositionRef.current - shift;
23280
+ const base = Math.abs(previousTarget - visual) < count ? previousTarget : Math.round(visual);
23281
+ const maxDistance = count - 1;
23282
+ return Math.min(Math.max(base + steps, Math.ceil(visual - maxDistance)), Math.floor(visual + maxDistance));
23283
+ });
23284
+ }, [count, isSlideTransition, moveTrack, setMoving]);
23238
23285
 
23239
23286
  const goBy = useCallback((step: 1 | -1) => {
23240
23287
  goBySteps(step);
@@ -23246,58 +23293,37 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23246
23293
  if (target === activeIndex && !isMovingRef.current) return;
23247
23294
  setAnimateDots(true);
23248
23295
  setMoving(true);
23249
- setActiveIndex(target);
23250
- if (isSlideTransition) {
23251
- const position = target + (hasClones ? 1 : 0);
23252
- pendingAnimatedPositionRef.current = null;
23253
- pendingStepsRef.current = 0;
23254
- trackPositionRef.current = position;
23255
- setSkipTransition(false);
23256
- setTrackPosition(position);
23296
+ if (!isSlideTransition) {
23297
+ setActiveIndex(target);
23298
+ return;
23257
23299
  }
23258
- }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23300
+ moveTrack(() => count + target);
23301
+ }, [activeIndex, count, isSlideTransition, moveTrack, setMoving]);
23259
23302
 
23260
23303
  useEffect(() => {
23261
23304
  if (!isMoving) return;
23262
23305
  const timeoutId = window.setTimeout(() => {
23263
- if (hasClones && (trackPosition === 0 || trackPosition === count + 1)) {
23264
- pendingAnimatedPositionRef.current = null;
23265
- setSkipTransition(true);
23266
- setTrackPosition(activeIndex + 1);
23267
- return;
23268
- }
23269
23306
  setMoving(false);
23270
- }, TRANSITION_DURATION_MS);
23307
+ if (!hasClones) return;
23308
+ const shift = getMiddleCopyShift(trackPosition, count);
23309
+ if (shift === 0) return;
23310
+ setSkipTransition(true);
23311
+ setTrackPosition(trackPosition - shift);
23312
+ }, transitionDurationMs);
23271
23313
  return () => window.clearTimeout(timeoutId);
23272
- }, [activeIndex, count, hasClones, isMoving, setMoving, trackPosition]);
23314
+ }, [count, hasClones, isMoving, setMoving, trackPosition, transitionDurationMs]);
23273
23315
 
23274
23316
  useEffect(() => {
23275
23317
  if (!skipTransition) return;
23276
23318
  let innerId = 0;
23277
23319
  const outerId = requestAnimationFrame(() => {
23278
- innerId = requestAnimationFrame(() => {
23279
- const pendingPosition = pendingAnimatedPositionRef.current;
23280
- pendingAnimatedPositionRef.current = null;
23281
- const pendingSteps = pendingStepsRef.current;
23282
- pendingStepsRef.current = 0;
23283
- setSkipTransition(false);
23284
- if (pendingPosition !== null) {
23285
- trackPositionRef.current = pendingPosition;
23286
- setTrackPosition(pendingPosition);
23287
- return;
23288
- }
23289
- if (pendingSteps !== 0) {
23290
- goBySteps(pendingSteps);
23291
- return;
23292
- }
23293
- setMoving(false);
23294
- });
23320
+ innerId = requestAnimationFrame(() => setSkipTransition(false));
23295
23321
  });
23296
23322
  return () => {
23297
23323
  cancelAnimationFrame(outerId);
23298
23324
  cancelAnimationFrame(innerId);
23299
23325
  };
23300
- }, [goBySteps, setMoving, skipTransition]);
23326
+ }, [skipTransition]);
23301
23327
 
23302
23328
  const structureKey = \`\${hasClones}:\${count}\`;
23303
23329
  const prevStructureKeyRef = useRef(structureKey);
@@ -23311,7 +23337,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23311
23337
  setDragOffset(0);
23312
23338
  setActiveIndex(nextIndex);
23313
23339
  setSkipTransition(true);
23314
- setTrackPosition(nextIndex + (hasClones ? 1 : 0));
23340
+ setTrackPosition(nextIndex + (hasClones ? count : 0));
23315
23341
  }, [activeIndex, count, hasClones, structureKey]);
23316
23342
 
23317
23343
  useEffect(() => {
@@ -23390,31 +23416,23 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23390
23416
  if (!isDragTrigger || count < 2 || !track) return;
23391
23417
  if (event.pointerType === 'mouse' && event.button !== 0) return;
23392
23418
 
23393
- pendingAnimatedPositionRef.current = null;
23394
- pendingStepsRef.current = 0;
23395
-
23396
23419
  if (isMovingRef.current) {
23397
23420
  setMoving(false);
23398
23421
  }
23399
23422
 
23423
+ // Freeze the track where it is on screen and drag from there.
23400
23424
  let baseOffset = 0;
23401
23425
  const list = listRef.current;
23402
23426
  if (isSlideTransition && list) {
23403
- const size = isHorizontal ? list.offsetWidth : list.offsetHeight;
23427
+ const size = readSlideSizePx(list, isHorizontal);
23404
23428
  if (size > 0) {
23405
- const currentPx = readTrackTranslatePx(list, isHorizontal);
23406
- let syncedPosition = trackPositionRef.current;
23407
- const isOnClone = hasClones && (syncedPosition === 0 || syncedPosition === count + 1);
23408
-
23409
- if (isOnClone) {
23410
- syncedPosition = activeIndex + 1;
23411
- trackPositionRef.current = syncedPosition;
23412
- setSkipTransition(true);
23413
- setTrackPosition(syncedPosition);
23414
- baseOffset = 0;
23415
- } else {
23416
- baseOffset = currentPx + syncedPosition * size;
23417
- }
23429
+ const visual = readVisualPosition();
23430
+ const middleVisual = hasClones ? visual - getMiddleCopyShift(visual, count) : visual;
23431
+ const basePosition = Math.round(middleVisual);
23432
+ baseOffset = (basePosition - middleVisual) * size;
23433
+ trackPositionRef.current = basePosition;
23434
+ setSkipTransition(true);
23435
+ setTrackPosition(basePosition);
23418
23436
  setDragOffset(baseOffset);
23419
23437
  }
23420
23438
  }
@@ -23480,19 +23498,19 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23480
23498
  finishDrag(event);
23481
23499
  };
23482
23500
 
23483
- const trackTranslate = isHorizontal
23484
- ? \`translate3d(calc(\${-trackPosition * 100}% + \${dragOffset}px), 0, 0)\`
23485
- : \`translate3d(0, calc(\${-trackPosition * 100}% + \${dragOffset}px), 0)\`;
23486
- const slides = hasClones ? [items[count - 1], ...items, items[0]] : items;
23501
+ const trackTranslate = getTrackTranslate(trackPosition, dragOffset, isHorizontal);
23502
+ const slides = hasClones ? Array.from({ length: TRACK_COPIES }, () => items).flat() : items;
23487
23503
 
23488
23504
  return (
23489
23505
  <>
23490
- <style dangerouslySetInnerHTML={{ __html: getCSS(P, isEditor) }} />
23506
+ <style dangerouslySetInnerHTML={{ __html: getCSS(P, transitionDurationMs, isEditor) }} />
23491
23507
  <div
23492
23508
  className={cn(\`\${P}-wrapper\`, {
23493
- [\`\${P}-transition-reveal\`]: transition === 'reveal',
23494
- [\`\${P}-transition-reveal-vertical\`]: transition === 'reveal' && !isHorizontal,
23509
+ [\`\${P}-transition-fade\`]: transition === 'fade in',
23510
+ [\`\${P}-transition-reveal\`]: isReveal,
23511
+ [\`\${P}-transition-reveal-vertical\`]: isReveal && !isHorizontal,
23495
23512
  })}
23513
+ data-active-index={activeIndex}
23496
23514
  onMouseEnter={() => setIsHovered(true)}
23497
23515
  onMouseLeave={() => setIsHovered(false)}
23498
23516
  >
@@ -23508,6 +23526,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23508
23526
  [\`\${P}-track-draggable\`]: isDragTrigger,
23509
23527
  [\`\${P}-track-draggable-vertical\`]: isDragTrigger && !isHorizontal,
23510
23528
  })}
23529
+ style={trackRadiusStyle}
23511
23530
  onPointerDown={handlePointerDown}
23512
23531
  onPointerMove={handlePointerMove}
23513
23532
  onPointerUp={handlePointerUp}
@@ -23530,38 +23549,29 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23530
23549
  transform: trackTranslate,
23531
23550
  transition: isDragging || skipTransition
23532
23551
  ? 'none'
23533
- : \`transform \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING}\`,
23552
+ : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`,
23534
23553
  }
23535
23554
  : undefined}
23536
23555
  >
23537
23556
  {slides.map((item, slideIndex) => {
23538
- const itemIndex = hasClones ? wrapIndex(slideIndex - 1, count) : slideIndex;
23539
- const isClone = hasClones && (slideIndex === 0 || slideIndex === count + 1);
23540
- const key = isClone
23541
- ? \`clone-\${slideIndex === 0 ? 'start' : 'end'}\`
23542
- : \`slide-\${itemIndex}\`;
23557
+ const itemIndex = wrapIndex(slideIndex, count);
23558
+ const key = \`slide-\${Math.floor(slideIndex / count)}-\${itemIndex}\`;
23543
23559
  return (
23544
- <div
23545
- key={key}
23546
- className={cn(\`\${P}-slide\`, {
23547
- [\`\${P}-is-active\`]: !isSlideTransition && itemIndex === activeIndex,
23548
- })}
23549
- >
23550
- <div className={\`\${P}-slider-item\`}>
23551
- <div className={\`\${P}-img-wrapper\`}>
23552
- <img
23553
- className={cn(\`\${P}-slider-image\`, {
23554
- [\`\${P}-contain\`]: item.image.objectFit === 'contain',
23555
- [\`\${P}-cover\`]: item.image.objectFit === 'cover'
23556
- })}
23557
- src={item.image.assetId} alt={item.image.name ?? ''}
23558
- draggable={false}
23559
- />
23560
- </div>
23561
- </div>
23560
+ <div key={key} className={\`\${P}-slide\`}>
23561
+ {renderSlideItem(item)}
23562
23562
  </div>
23563
23563
  );
23564
23564
  })}
23565
+ {isLayered && transitionLayers.map((layer, layerPosition) => (
23566
+ <div
23567
+ key={\`layer-\${layer.key}\`}
23568
+ className={cn(\`\${P}-slide\`, \`\${P}-is-layer\`)}
23569
+ style={{ zIndex: layerPosition + 1 }}
23570
+ onAnimationEnd={() => handleLayerEnd(layer.key)}
23571
+ >
23572
+ {renderSlideItem(items[layer.index])}
23573
+ </div>
23574
+ ))}
23565
23575
  </div>
23566
23576
  {isClickTrigger && (
23567
23577
  <div
@@ -23733,7 +23743,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23733
23743
  style={{
23734
23744
  ...titleStyle,
23735
23745
  width: TITLE_WIDTH_SETTINGS.sizing === 'auto' ? 'max-content' : scalingValue(TITLE_WIDTH_SETTINGS.width, isEditor),
23736
- transitionDuration: \`\${Math.round(TRANSITION_DURATION_MS / 2)}ms\`,
23746
+ transitionDuration: \`\${Math.round(transitionDurationMs / 2)}ms\`,
23737
23747
  }}
23738
23748
  >
23739
23749
  <div
@@ -25427,4 +25437,4 @@ export function Waterfall({
25427
25437
  </>
25428
25438
  );
25429
25439
  }
25430
- `,w={[n.BurgerComponent.id]:e,[n.ChroniclesComponent.id]:t,[n.ClickGallerieComponent.id]:i,[n.FAQComponent.id]:o,[n.FormComponent.id]:r,[n.GridComponent.id]:a,[n.HelixComponent.id]:s,[n.HiveComponent.id]:l,[n.LightboxJournalComponent.id]:c,[n.LightboxStripComponent.id]:d,[n.ListComponent.id]:u,[n.MarqueeComponent.id]:g,[n.MarqueeTextComponent.id]:m,[n.MercuryComponent.id]:p,[n.OnelinerFormComponent.id]:h,[n.PretextComponent.id]:f,[n.ScaleComponent.id]:v,[n.SimpleButtonComponent.id]:P,[n.Slider20Component.id]:x,[n.TestimonialGridComponent.id]:b,[n.TestimonialSingleComponent.id]:y,[n.WaterfallComponent.id]:S};exports.componentSources=w;
25440
+ `,w={[n.BurgerComponent.id]:e,[n.ChroniclesComponent.id]:t,[n.ClickGallerieComponent.id]:i,[n.FAQComponent.id]:o,[n.FormComponent.id]:r,[n.GridComponent.id]:a,[n.HelixComponent.id]:s,[n.HiveComponent.id]:l,[n.LightboxJournalComponent.id]:d,[n.LightboxStripComponent.id]:c,[n.ListComponent.id]:u,[n.MarqueeComponent.id]:g,[n.MarqueeTextComponent.id]:m,[n.MercuryComponent.id]:p,[n.OnelinerFormComponent.id]:h,[n.PretextComponent.id]:f,[n.ScaleComponent.id]:v,[n.SimpleButtonComponent.id]:P,[n.Slider20Component.id]:x,[n.TestimonialGridComponent.id]:b,[n.TestimonialSingleComponent.id]:y,[n.WaterfallComponent.id]:S};exports.componentSources=w;