diff --git a/docs/storybook/content/stories/99-tests/clip.test.stories.tsx b/docs/storybook/content/stories/99-tests/clip.test.stories.tsx index 03ab283..0ffa002 100644 --- a/docs/storybook/content/stories/99-tests/clip.test.stories.tsx +++ b/docs/storybook/content/stories/99-tests/clip.test.stories.tsx @@ -44,6 +44,9 @@ ClipBoth.play = async ({ canvasElement }) => { const [itemOne, itemTwo] = Array.from( sliderRoot.querySelectorAll('[data-rcs="clip-item"]'), ) as HTMLElement[]; + + expect(itemOne).toBeVisible(); + expect(itemTwo).toBeVisible(); expect(itemOne?.style.clipPath).toBe('inset(0px 25% 0px 0px)'); expect(itemTwo?.style.clipPath).toBe('inset(0px 0px 0px 75%)'); }); @@ -66,6 +69,9 @@ ClipItemOne.play = async ({ canvasElement }) => { const [itemOne, itemTwo] = Array.from( sliderRoot.querySelectorAll('[data-rcs="clip-item"]'), ) as HTMLElement[]; + + expect(itemOne).toBeVisible(); + expect(itemTwo).toBeVisible(); expect(itemOne?.style.clipPath).toBe('inset(0px 50% 0px 0px)'); expect(itemTwo?.style.clipPath).toBe('none'); }); @@ -83,6 +89,9 @@ ClipItemOne.play = async ({ canvasElement }) => { const [itemOne, itemTwo] = Array.from( sliderRoot.querySelectorAll('[data-rcs="clip-item"]'), ) as HTMLElement[]; + + expect(itemOne).toBeVisible(); + expect(itemTwo).toBeVisible(); expect(itemOne?.style.clipPath).toBe('inset(0px 25% 0px 0px)'); expect(itemTwo?.style.clipPath).toBe('none'); }); diff --git a/lib/src/Container.tsx b/lib/src/Container.tsx index 15d4274..f2a7104 100644 --- a/lib/src/Container.tsx +++ b/lib/src/Container.tsx @@ -5,13 +5,14 @@ import type { ReactCompareSliderCommonProps } from './types'; type ContainerItemProps = ComponentPropsWithoutRef<'div'> & Pick & { + shouldOverlap?: boolean; order?: number; }; /** Container for clipped item. */ export const ContainerItem = forwardRef( - ({ transition, order, ...props }, ref): ReactElement => { - const style: CSSProperties = { + ({ shouldOverlap, order, style, transition, ...props }, ref): ReactElement => { + const appliedStyle: CSSProperties = { gridArea: '1 / 1 / 2 / 2', order, maxWidth: '100%', @@ -20,12 +21,14 @@ export const ContainerItem = forwardRef( transition: transition ? `clip-path ${transition}` : undefined, userSelect: 'none', willChange: 'clip-path, transition', + zIndex: shouldOverlap ? 1 : undefined, KhtmlUserSelect: 'none', MozUserSelect: 'none', WebkitUserSelect: 'none', + ...style, }; - return
; + return
; }, ); @@ -50,6 +53,7 @@ export const ContainerHandle = forwardRef - + {itemOne}