-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make turntable completely controllable from the parent element, c…
…loses #24 BREAKING CHANGE: The library now requires the `useReactImageTurntable` hook to be called and its props passed.
- Loading branch information
Showing
11 changed files
with
170 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
export * from './ReactImageTurntable'; | ||
export type { ReactImageTurntableProps, ReactImageTurntableFullProps } from './types'; | ||
export * from './useReactImageTurntable'; | ||
export type { | ||
UseReactImageTurntableProps, | ||
ReactImageTurntableRootProps, | ||
UseReactImageTurntableReturn, | ||
} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
import type { HtmlHTMLAttributes } from 'react'; | ||
import type { HtmlHTMLAttributes, RefObject } from 'react'; | ||
|
||
export interface ReactImageTurntableProps { | ||
export interface UseReactImageTurntableProps { | ||
/** The array index of the active image. */ | ||
initialImageIndex?: number; | ||
/** Properties to automatically rotate the turntable. */ | ||
autoRotate?: { | ||
/** Enable or disable the autorotation of the turntable. */ | ||
disabled?: boolean; | ||
/** The speed (in ms) at which the turntable rotates. */ | ||
interval?: number; | ||
}; | ||
/** List of image `src` attributes. */ | ||
images: string[]; | ||
/** Index of image to show first. */ | ||
initialImageIndex?: number; | ||
/** The amount a "drag" has to move before an image changes to next or previous. */ | ||
movementSensitivity?: number; | ||
/** Callback that triggers whenever the active index changes. */ | ||
onIndexChange?: (index: number) => void; | ||
autoRotate?: { | ||
/** Automatically rotate the turntable. */ | ||
disabled: boolean; | ||
/** The speed (in ms) at which the turntable rotates. */ | ||
interval?: number; | ||
}; | ||
} | ||
|
||
export interface UseReactImageTurntableReturn extends Pick<UseReactImageTurntableProps, 'images'> { | ||
/** The array index of the active image. */ | ||
activeImageIndex: number; | ||
/** Function to programatically set the active image index. */ | ||
setActiveImageIndex: (index: number) => void; | ||
/** The ref to the root turntable element. */ | ||
turntableRef: RefObject<HTMLDivElement>; | ||
} | ||
|
||
/** Base props *and* all available HTML element props. */ | ||
export type ReactImageTurntableFullProps = HtmlHTMLAttributes<HTMLDivElement> & | ||
ReactImageTurntableProps; | ||
export type ReactImageTurntableRootProps = HtmlHTMLAttributes<HTMLDivElement> & | ||
UseReactImageTurntableReturn; |
Oops, something went wrong.