Skip to content

Commit

Permalink
feat(goTo): add option to skip transition for goTo method
Browse files Browse the repository at this point in the history
  • Loading branch information
femioladeji committed Dec 10, 2022
1 parent 731d7f6 commit fb42e36
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-slideshow-image",
"version": "4.0.5",
"version": "4.1.0",
"description": "An image slideshow with react",
"license": "MIT",
"main": "dist/index.js",
Expand Down
8 changes: 6 additions & 2 deletions src/fadezoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ export const FadeZoom = React.forwardRef<SlideshowRef, ZoomProps>((props, ref) =
goBack: () => {
moveBack();
},
goTo: (index: number) => {
moveTo(index);
goTo: (index: number, options?: { skipTransition?: boolean }) => {
if (options?.skipTransition) {
setIndex(index);
} else {
moveTo(index);
}
},
}));

Expand Down
8 changes: 6 additions & 2 deletions src/slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ export const Slide = React.forwardRef<SlideshowRef, SlideProps>((props, ref) =>
goBack: () => {
moveBack();
},
goTo: (index: number) => {
moveTo(index);
goTo: (index: number, options?: { skipTransition?: boolean }) => {
if (options?.skipTransition) {
setIndex(index);
} else {
moveTo(index);
}
},
}));

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ export type TweenEasingFn = (amount: number) => number;
export type SlideshowRef = {
goNext: () => void;
goBack: () => void;
goTo: (index: number) => void;
goTo: (index: number, options?: { skipTransition?: boolean }) => void;
};
3 changes: 2 additions & 1 deletion stories/Methods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { Slide } from '../src';
## Methods Slides

The package supports three methods that can be used to control navigation. The `goBack()` method shows the previous slide while `goNext()` shows the next slide.
The `goTo(index)` method goes to a particular index. It takes an integer as the parameter.
The `goTo(index)` method goes to a particular index. It takes an integer as the parameter. You can also pass a second parameter of options e.g `{ skipTransition: true }`. This
will ensure that the next index shows without any transition

```tsx
import React from 'react';
Expand Down

0 comments on commit fb42e36

Please sign in to comment.