-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add support for the overflow event #57
base: master
Are you sure you want to change the base?
Conversation
Thanks for the work, would greatly appreciate if this PR could be merged soon! I'm currently using an intersection observer as workaround, but would be nice if we could use the native API. |
@tom-bywild mind sharing that observer code with me until this get's merged? |
For anyone else coming across the same issue, you can actually use the Splide API for it. Here's a simple piece of code to determine what end of container should show its control (React code), the callback names map to the respective names on the Splide-element. const [visibleControls, setVisibleControls] = useState<[boolean, boolean]>([false, false]);
const onMounted = useCallback((instance: Splide) => {
const end = instance.Components.Controller.getEnd();
setVisibleControls(() => [false, end !== 0]);
}, []);
const onMove = useCallback((instance: Splide, i: number) => {
const end = instance.Components.Controller.getEnd();
setVisibleControls(() => [i !== 0, i !== end]);
}, []);
const onOverflow = useCallback((_: Splide, isOverflow: boolean) => {
setVisibleControls((prev) => [prev[0], isOverflow]);
}, []); Edit: I forgot to mention that I used |
@tom-bywild I'm trying to get this working... but it doesn't seem to work. const onOverflow = useCallback((splide: Splide, isOverflow: boolean) => {
console.log(isOverflow);
splide.options = {
arrows: isOverflow,
drag: isOverflow,
autoStart: isOverflow
};
splide.Components?.AutoScroll?.pause();
}, []); |
@NaotoshiFujita do you mind taking a quick look at this and merging it? Thank you! |
@NaotoshiFujita : indeed a fix for this would be really appreciated! any plans on merging the pr? |
@NaotoshiFujita Hey! It has been a while since this PR was created, would it be possible to merge it? Thank you in advance |
Hello????? |
In the meantime I made it work using patch-package This is the code generated when running patch-package with the changes I made in case is useful for you diff --git a/node_modules/@splidejs/react-splide/dist/js/react-splide.cjs.js b/node_modules/@splidejs/react-splide/dist/js/react-splide.cjs.js
// src/js/utils/classNames/classNames.ts
// src/js/utils/classNames/classNames.ts
export type SplideEventHandlers = { |
Bump, I'd like to make use of this too :) @NaotoshiFujita |
Bumping for @Seresigo too |
Related Issues
#56
Description
This PR fixes the lack of an overflow event to the React version of Splide.