yet-another-react-lightbox 2.5.0 → 2.5.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.
@@ -5,7 +5,6 @@ import { LightboxStateAction } from "../contexts/index.js";
5
5
  import { ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, YARL_EVENT_BACKDROP_CLICK } from "../consts.js";
6
6
  export type NavigationAction = {
7
7
  count?: number;
8
- animationDuration?: number;
9
8
  };
10
9
  declare module "../" {
11
10
  interface EventTypes {
@@ -54,8 +54,8 @@ export const Controller = ({ children, ...props }) => {
54
54
  });
55
55
  const swipe = useEventCallback((action) => {
56
56
  var _a, _b;
57
- const swipeDuration = (_a = action.animationDuration) !== null && _a !== void 0 ? _a : animation.swipe;
58
57
  const currentSwipeOffset = action.offset || 0;
58
+ const swipeDuration = (_a = (!currentSwipeOffset ? animation.navigation : undefined)) !== null && _a !== void 0 ? _a : animation.swipe;
59
59
  let { direction } = action;
60
60
  const count = (_b = action.count) !== null && _b !== void 0 ? _b : 1;
61
61
  let newSwipeState = SwipeState.ANIMATION;
@@ -14,10 +14,7 @@ export const Navigation = ({ slides, carousel: { finite }, animation: { swipe, n
14
14
  const isRTL = useRTL();
15
15
  const prevDisabled = slides.length === 0 || (finite && currentIndex === 0);
16
16
  const nextDisabled = slides.length === 0 || (finite && currentIndex === slides.length - 1);
17
- const navigate = (action) => {
18
- publish(action, { animationDuration: navigation });
19
- };
20
- const publishThrottled = useThrottle((action) => navigate(action), (navigation !== null && navigation !== void 0 ? navigation : swipe) / 2);
17
+ const publishThrottled = useThrottle((action) => publish(action), (navigation !== null && navigation !== void 0 ? navigation : swipe) / 2);
21
18
  const handleKeyDown = useEventCallback((event) => {
22
19
  if (event.key === VK_ARROW_LEFT && !(isRTL ? nextDisabled : prevDisabled)) {
23
20
  publishThrottled(isRTL ? ACTION_NEXT : ACTION_PREV);
@@ -28,7 +25,7 @@ export const Navigation = ({ slides, carousel: { finite }, animation: { swipe, n
28
25
  });
29
26
  React.useEffect(() => subscribeSensors(EVENT_ON_KEY_DOWN, handleKeyDown), [subscribeSensors, handleKeyDown]);
30
27
  return (React.createElement(React.Fragment, null,
31
- buttonPrev ? (buttonPrev()) : (React.createElement(NavigationButton, { label: "Previous", action: ACTION_PREV, icon: PreviousIcon, renderIcon: iconPrev, disabled: prevDisabled, labels: labels, onClick: () => navigate(ACTION_PREV) })),
32
- buttonNext ? (buttonNext()) : (React.createElement(NavigationButton, { label: "Next", action: ACTION_NEXT, icon: NextIcon, renderIcon: iconNext, disabled: nextDisabled, labels: labels, onClick: () => navigate(ACTION_NEXT) }))));
28
+ buttonPrev ? (buttonPrev()) : (React.createElement(NavigationButton, { label: "Previous", action: ACTION_PREV, icon: PreviousIcon, renderIcon: iconPrev, disabled: prevDisabled, labels: labels, onClick: () => publish(ACTION_PREV) })),
29
+ buttonNext ? (buttonNext()) : (React.createElement(NavigationButton, { label: "Next", action: ACTION_NEXT, icon: NextIcon, renderIcon: iconNext, disabled: nextDisabled, labels: labels, onClick: () => publish(ACTION_NEXT) }))));
33
30
  };
34
31
  export const NavigationModule = createModule(MODULE_NAVIGATION, Navigation);
@@ -7,10 +7,8 @@ export const Description = ({ description, descriptionTextAlign, descriptionMaxL
7
7
  ...(descriptionTextAlign !== defaultCaptionsProps.descriptionTextAlign ||
8
8
  descriptionMaxLines !== defaultCaptionsProps.descriptionMaxLines
9
9
  ? {
10
- style: {
11
- [cssVar("slide_description_text_align")]: descriptionTextAlign,
12
- [cssVar("slide_description_max_lines")]: descriptionMaxLines,
13
- },
10
+ [cssVar("slide_description_text_align")]: descriptionTextAlign,
11
+ [cssVar("slide_description_max_lines")]: descriptionMaxLines,
14
12
  }
15
13
  : null),
16
14
  ...styles.captionsDescription,
@@ -5,7 +5,7 @@ import { Thumbnail } from "./Thumbnail.js";
5
5
  import { defaultThumbnailsProps } from "./Thumbnails.js";
6
6
  const isHorizontal = (position) => ["top", "bottom"].includes(position);
7
7
  const boxSize = (thumbnails, dimension, includeGap) => dimension + 2 * (thumbnails.border + thumbnails.padding) + (includeGap ? thumbnails.gap : 0);
8
- export const ThumbnailsTrack = ({ container, slides, carousel, render, thumbnails, thumbnailRect, styles, animation: { navigation }, }) => {
8
+ export const ThumbnailsTrack = ({ container, slides, carousel, render, thumbnails, thumbnailRect, styles, }) => {
9
9
  const track = React.useRef(null);
10
10
  const { globalIndex, animation } = useLightboxState().state;
11
11
  const { publish, subscribe } = useEvents();
@@ -78,10 +78,10 @@ export const ThumbnailsTrack = ({ container, slides, carousel, render, thumbnail
78
78
  }
79
79
  const handleClick = (slideIndex) => () => {
80
80
  if (slideIndex > index) {
81
- publish(ACTION_NEXT, { count: slideIndex - index, animationDuration: navigation });
81
+ publish(ACTION_NEXT, { count: slideIndex - index });
82
82
  }
83
83
  else if (slideIndex < index) {
84
- publish(ACTION_PREV, { count: index - slideIndex, animationDuration: navigation });
84
+ publish(ACTION_PREV, { count: index - slideIndex });
85
85
  }
86
86
  };
87
87
  const { width, height, border, borderRadius, padding, gap, imageFit, vignette } = thumbnails;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",