diff --git a/README.md b/README.md index 91323f8..24e8175 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ export default YourComponent; `goToPreviousStory` | () => void | Goes to previous story item `goToNextStory` | () => void | Goes to next story item `getCurrentStory` | () => {userId?: string, storyId?: string} | Returns current userId and storyId + `goToSpecificStory` | ( userId: string, index: number ) => void | Change current playing story to defined index if index not exist then start playing first story ## Types diff --git a/src/components/InstagramStories/index.tsx b/src/components/InstagramStories/index.tsx index ab743de..26c9b33 100644 --- a/src/components/InstagramStories/index.tsx +++ b/src/components/InstagramStories/index.tsx @@ -175,6 +175,7 @@ const InstagramStories = forwardRef modalRef.current?.goToSpecificStory( userId, index ), hide: () => modalRef.current?.hide(), show: ( id ) => { diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index 4ce9fa8..06c18fd 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -423,6 +423,7 @@ const StoryModal = forwardRef( ( { getCurrentStory: () => ( { userId: userId.value, storyId: currentStory.value } ), goToPreviousStory: toPreviousStory, goToNextStory: toNextStory, + goToSpecificStory: ( newUserId, index ) => scrollTo( newUserId, true, false, undefined, index ), } ), [ userId.value, currentStory.value ] ); useEffect( () => { diff --git a/src/core/dto/componentsDTO.ts b/src/core/dto/componentsDTO.ts index 10b738a..3b5a85f 100644 --- a/src/core/dto/componentsDTO.ts +++ b/src/core/dto/componentsDTO.ts @@ -63,6 +63,7 @@ export type StoryModalPublicMethods = { goToPreviousStory: () => void; goToNextStory: () => void; getCurrentStory: () => { userId?: string, storyId?: string }; + goToSpecificStory: ( userId: string, index?: number ) => void; }; export type GestureContext = { diff --git a/src/core/dto/instagramStoriesDTO.ts b/src/core/dto/instagramStoriesDTO.ts index a37bf7e..abac9f5 100644 --- a/src/core/dto/instagramStoriesDTO.ts +++ b/src/core/dto/instagramStoriesDTO.ts @@ -94,4 +94,5 @@ export type InstagramStoriesPublicMethods = { goToPreviousStory: () => void; goToNextStory: () => void; getCurrentStory: () => { userId?: string, storyId?: string }; + goToSpecificStory: ( userId: string, index?: number ) => void; };