@@ -2831,7 +2831,14 @@ function RemoteFunctions(config = {}) {
28312831 if ( ! container ) { return ; }
28322832
28332833 const containerWidth = container . clientWidth ;
2834- const scrollAmount = containerWidth ;
2834+ const imageWidth = 117 ; // image width + gap
2835+
2836+ // calculate how many images are visible
2837+ const visibleImages = Math . floor ( containerWidth / imageWidth ) ;
2838+
2839+ // scroll by (visible images - 2), minimum 1 image, maximum 5 images
2840+ const imagesToScroll = Math . max ( 1 , Math . min ( 5 , visibleImages - 2 ) ) ;
2841+ const scrollAmount = imagesToScroll * imageWidth ;
28352842
28362843 this . scrollPosition = Math . max ( 0 , this . scrollPosition - scrollAmount ) ;
28372844 container . scrollTo ( { left : this . scrollPosition , behavior : 'smooth' } ) ;
@@ -2844,7 +2851,14 @@ function RemoteFunctions(config = {}) {
28442851
28452852 const containerWidth = container . clientWidth ;
28462853 const totalWidth = container . scrollWidth ;
2847- const scrollAmount = containerWidth ;
2854+ const imageWidth = 117 ; // image width + gap
2855+
2856+ // calculate how many images are visible
2857+ const visibleImages = Math . floor ( containerWidth / imageWidth ) ;
2858+
2859+ // scroll by (visible images - 2), minimum 1 image, maximum 5 images
2860+ const imagesToScroll = Math . max ( 1 , Math . min ( 5 , visibleImages - 2 ) ) ;
2861+ const scrollAmount = imagesToScroll * imageWidth ;
28482862
28492863 // if we're near the end, we need to load more images
28502864 const nearEnd = ( this . scrollPosition + containerWidth + scrollAmount ) >= totalWidth - 100 ;
0 commit comments