diff --git a/stories/slideshow.module.css b/stories/slideshow.module.css index 2c0702e..599a497 100644 --- a/stories/slideshow.module.css +++ b/stories/slideshow.module.css @@ -44,6 +44,10 @@ scroll-snap-align: start; } +.snapStop { + scroll-snap-stop: always; +} + .itemText { position: absolute; z-index: 100; diff --git a/stories/slideshow.stories.tsx b/stories/slideshow.stories.tsx index 00408d3..d3e9826 100644 --- a/stories/slideshow.stories.tsx +++ b/stories/slideshow.stories.tsx @@ -60,3 +60,22 @@ export const ScrollPadding = () => { /> ); }; + +export const SnapEachSlide = () => { + return ( + ( + + )} + /> + ); +}; diff --git a/stories/slideshow.tsx b/stories/slideshow.tsx index 1786efb..a69d1ec 100644 --- a/stories/slideshow.tsx +++ b/stories/slideshow.tsx @@ -45,18 +45,18 @@ export const SlideShow = ({ const handle = (e: KeyboardEvent) => { switch (e.key) { case 'ArrowLeft': - next(); + prev(); return; case 'ArrowRight': - prev(); + next(); return; default: return; } }; - window.addEventListener('keypress', handle); + window.addEventListener('keydown', handle); return () => { - window.removeEventListener('keypress', handle); + window.removeEventListener('keydown', handle); }; }, [next, prev]); @@ -118,6 +118,7 @@ export const SlideShow = ({ export interface SlideShowItemProps { readonly isSnapPoint: boolean; + readonly isSnapStop?: boolean; readonly isActive: boolean; readonly src: string; readonly title: string; @@ -126,6 +127,7 @@ export interface SlideShowItemProps { export const SlideShowItem = ({ isSnapPoint, + isSnapStop, isActive, src, title, @@ -135,6 +137,7 @@ export const SlideShowItem = ({