Centered Scroll Target: Updated scroll logic to ensure that the next or previous gallery item is always scrolled into the center of the view. The findCurrentItem function now calculates the item closest to the center, improving user experience by always focusing on the current or next image.
Implementation Notes:
Refactor for Readability: Simplified the calcScrollSize method by ensuring proper type checks and type assertions using TypeScript. Cleaned up redundant code for better clarity and maintainability.
Reduced Code Duplication: Introduced a shared scrollToPage function for both 'next' and 'prev' page scrolls, replacing the previous repetitive logic and centralizing scroll behavior in one place.
Improved Scroll Targeting: The new findCurrentItem function now accurately identifies the item closest to the center of the scroller viewport, ensuring that the next item scrolls into the center smoothly.
Functionality Changes:
Centered Scroll Target: Updated scroll logic to ensure that the next or previous gallery item is always scrolled into the center of the view. The
findCurrentItem
function now calculates the item closest to the center, improving user experience by always focusing on the current or next image.Implementation Notes:
calcScrollSize
method by ensuring proper type checks and type assertions using TypeScript. Cleaned up redundant code for better clarity and maintainability.scrollToPage
function for both 'next' and 'prev' page scrolls, replacing the previous repetitive logic and centralizing scroll behavior in one place.findCurrentItem
function now accurately identifies the item closest to the center of the scroller viewport, ensuring that the next item scrolls into the center smoothly.Resolves: