diff --git a/package.json b/package.json index 375695f..24b7e75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-slideshow-image", - "version": "4.0.0", + "version": "4.0.1", "description": "An image slideshow with react", "license": "MIT", "main": "dist/index.js", diff --git a/src/fade.tsx b/src/fade.tsx index 0594927..1598189 100644 --- a/src/fade.tsx +++ b/src/fade.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { FadeZoom } from './fadezoom'; import { defaultProps } from './props'; -import { FadeProps } from './types'; +import { FadeProps, SlideshowRef } from './types'; -export const Fade = React.forwardRef((props: FadeProps, ref) => { +export const Fade = React.forwardRef((props, ref) => { return ; }); diff --git a/src/fadezoom.tsx b/src/fadezoom.tsx index 4b42bd1..42d5320 100644 --- a/src/fadezoom.tsx +++ b/src/fadezoom.tsx @@ -15,10 +15,10 @@ import { showNextArrow, showPreviousArrow, } from './helpers'; -import { ButtonClick, ZoomProps } from './types'; +import { ButtonClick, SlideshowRef, ZoomProps } from './types'; import { defaultProps } from './props'; -export const FadeZoom = React.forwardRef((props: ZoomProps, ref) => { +export const FadeZoom = React.forwardRef((props, ref) => { const [index, setIndex] = useState( getStartingIndex(props.children, props.defaultIndex) ); diff --git a/src/index.tsx b/src/index.tsx index 3b63222..18ad32e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,4 +4,4 @@ export { Fade } from './fade'; export { Zoom } from './zoom'; export { Slide } from './slide'; -export { FadeProps, ZoomProps, SlideProps } from './types'; +export { FadeProps, ZoomProps, SlideProps, SlideshowRef } from './types'; diff --git a/src/slide.tsx b/src/slide.tsx index e86be08..272e7c0 100644 --- a/src/slide.tsx +++ b/src/slide.tsx @@ -15,10 +15,10 @@ import { showNextArrow, showPreviousArrow, } from './helpers'; -import { ButtonClick, SlideProps } from './types'; +import { ButtonClick, SlideshowRef, SlideProps } from './types'; import { defaultProps } from './props'; -export const Slide = React.forwardRef((props: SlideProps, ref) => { +export const Slide = React.forwardRef((props, ref) => { const [index, setIndex] = useState(getStartingIndex(props.children, props.defaultIndex)); const [wrapperWidth, setWrapperWidth] = useState(0); const wrapperRef = useRef(null); diff --git a/src/types.ts b/src/types.ts index 8247b2c..c98784d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -66,3 +66,9 @@ export type IndicatorPropsType = { }; export type TweenEasingFn = (amount: number) => number; + +export type SlideshowRef = { + goNext: () => void; + goBack: () => void; + goTo: (index: number) => void; +}; diff --git a/src/zoom.tsx b/src/zoom.tsx index a755160..7b09af9 100644 --- a/src/zoom.tsx +++ b/src/zoom.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { FadeZoom } from './fadezoom'; import { defaultProps } from './props'; -import { ZoomProps } from './types'; +import { SlideshowRef, ZoomProps } from './types'; -export const Zoom = React.forwardRef((props: ZoomProps, ref) => { +export const Zoom = React.forwardRef((props, ref) => { return ; }); diff --git a/stories/Methods.mdx b/stories/Methods.mdx index 96e5cbf..acb470d 100644 --- a/stories/Methods.mdx +++ b/stories/Methods.mdx @@ -10,11 +10,11 @@ The `goTo(index)` method goes to a particular index. It takes an integer as the ```tsx import React from 'react'; -import { Slide } from 'react-slideshow-image'; +import { Slide, SlideshowRef } from 'react-slideshow-image'; import 'react-slideshow-image/dist/styles.css'; const Example = () => { - const slideRef = useRef(null) + const slideRef = useRef(null) return ( <> @@ -25,7 +25,7 @@ const Example = () => {
- + slideRef.current.goTo(parseInt(event.currentTarget.value))}>