-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add autorotate #17
Conversation
Thanks for opening this @webmarkyn, it's a great feature! I'll take a look at it today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this feature @webmarkyn!
I've left a pretty minor tweak for the autoRotate
prop in the review.
Also, I think it should continue rotating after the user stops interacting with the component too, what do you reckon?
Example scenario with autoRotate.disabled: false
:
- Stop autorotation while pointer down
- Resume autorotation on pointer up
It would be better this way IMO since the default behaviour would always do what the autoRotate.disabled
prop says rather than only doing it once. This means a developer could choose to disable autorotation if they wanted be adding a pointerdown
event to the turntable and disable it themselves if thet wanted to.
E.g.
// Developer can choose to disable autorotation themselves if they want to.
const SomeComponent = () => {
const [disabled, setDisabled] = useState(false);
const onPointerDown = () => {
setDisabled(true);
}
return (
<ReactImageTurntable
autoRotate={{ disabled }}
onPointerDown={onPointerDown}
/>
);
};
enabled: boolean; | ||
/** The speed (in ms) at which the turntable rotates. */ | ||
speed?: number; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think autoRotate.enabled
could be replaced with an optional autoRotate.disabled
prop and speed
could be renamed to interval
like you've done in the internal lib code to more closely describe what it does.
// type
{
autoRotate?: {
/** Whether to disable the autorotation of the turntable. */
disabled?: boolean;
/** The speed (in ms) at which the turntable rotates. */
interval?: number;
};
}
// default value
autoRotate = { disabled: true, interval: 200 }
@nerdyman thanks for the review. Made the changes you requested, please take a look. |
@nerdyman Hello. Can you check the PR please? |
Hi Mark, unfortunately I got really bad food poisoning over the weekend and
had to go the hospital so I won't be able to review for another day or two.
…On Tue, 21 Nov 2023 at 11:31, Mark Baidebura ***@***.***> wrote:
@nerdyman <https://github.com/nerdyman> Hello. Can you check the PR
please?
—
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFOLED24HU6TZEBMZMUEDTYFSGHRAVCNFSM6AAAAAA7N4QDIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRQG42DCOBUGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@nerdyman Sorry to hear that. Take care. |
Thanks for your work and patience on this @webmarkyn! |
Turntable is automatically rotated if
autorotate
prop hasenabled
property set totrue
. Autorotation is disabled as soon as mousedown/keydown events are fired.