@obosbbl/grunnmuren-react 3.3.3 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +11 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1041,11 +1041,17 @@ const Carousel = ({ className, children, onChange, ...rest })=>{
1041
1041
  }
1042
1042
  isScrollingProgrammatically.current = true;
1043
1043
  const elementWithFocusVisible = carouselRef.current?.querySelector(':focus-visible');
1044
- carouselItemsRef.current.children[scrollTargetIndex]?.scrollIntoView({
1045
- behavior: prefersReducedMotion ? 'instant' : 'smooth',
1046
- inline: 'start',
1047
- block: 'nearest'
1048
- });
1044
+ const targetElement = carouselItemsRef.current.children[scrollTargetIndex];
1045
+ if (targetElement) {
1046
+ // Calculate the scroll position to scroll the target element into view
1047
+ const containerRect = carouselItemsRef.current.getBoundingClientRect();
1048
+ const targetRect = targetElement.getBoundingClientRect();
1049
+ const scrollLeft = carouselItemsRef.current.scrollLeft + (targetRect.left - containerRect.left);
1050
+ carouselItemsRef.current.scrollTo({
1051
+ left: Math.round(scrollLeft),
1052
+ behavior: prefersReducedMotion ? 'instant' : 'smooth'
1053
+ });
1054
+ }
1049
1055
  if (prevIndex.current !== scrollTargetIndex && onChange) {
1050
1056
  onChange({
1051
1057
  index: scrollTargetIndex,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"