Uh oh!
There was an error while loading. Please reload this page.
Add support for the overflow event - #57
Conversation
tom-bywild
commented
Jan 27, 2023
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. |
xKrvZ
commented
Mar 10, 2023
@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]);constonMounted=useCallback((instance: Splide)=>{constend=instance.Components.Controller.getEnd();setVisibleControls(()=>[false,end!==0]);},[]);constonMove=useCallback((instance: Splide,i: number)=>{constend=instance.Components.Controller.getEnd();setVisibleControls(()=>[i!==0,i!==end]);},[]);constonOverflow=useCallback((_: Splide,isOverflow: boolean)=>{setVisibleControls((prev)=>[prev[0],isOverflow]);},[]);Edit: I forgot to mention that I used |
xKrvZ
commented
Mar 10, 2023
@tom-bywild I'm trying to get this working... but it doesn't seem to work. constonOverflow=useCallback((splide: Splide,isOverflow: boolean)=>{console.log(isOverflow);splide.options={arrows: isOverflow,drag: isOverflow,autoStart: isOverflow};splide.Components?.AutoScroll?.pause();},[]); |
martinbavio
commented
Apr 15, 2023
@NaotoshiFujita do you mind taking a quick look at this and merging it? Thank you! |
puck3000
commented
May 9, 2023
@NaotoshiFujita : indeed a fix for this would be really appreciated! any plans on merging the pr? |
SergioVanacloigCarlsberg
commented
Jun 26, 2023
@NaotoshiFujita Hey! It has been a while since this PR was created, would it be possible to merge it? Thank you in advance |
xKrvZ
commented
Jun 28, 2023
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 = { |
jasien-eurostar
commented
Nov 17, 2023
Bump, I'd like to make use of this too :) @NaotoshiFujita |
jasien-eurostar
commented
Nov 17, 2023
Bumping for @Seresigo too |
CodingWatchCollector
commented
Mar 18, 2025
While waiting for the PR to be merged, for anyone looking for a solution without using <SplideonResized={(splide)=>{constelement=splide.root;element.clientWidth<splide.Components.Layout.sliderSize()
? element.classList.add(styles.overflow)// overflow
: element.classList.remove(styles.overflow);// no overflow}}.../> |
Related Issues
#56
Description
This PR fixes the lack of an overflow event to the React version of Splide.