diff --git a/packages/_vue3-migration-test/src/components/animations/index.ts b/packages/_vue3-migration-test/src/components/animations/index.ts
index b951da74a4..ca0d8338a1 100644
--- a/packages/_vue3-migration-test/src/components/animations/index.ts
+++ b/packages/_vue3-migration-test/src/components/animations/index.ts
@@ -5,3 +5,4 @@ export { default as TestCrossFade } from './test-cross-fade.vue';
export { default as TestFade } from './test-fade.vue';
export { default as TestFadeAndSlide } from './test-fade-and-slide.vue';
export { default as TestAnimationFactory } from './test-animation-factory.vue';
+export { default as TestStaggeredFadeAndSlide } from './test-staggered-fade-and-slide.vue';
diff --git a/packages/_vue3-migration-test/src/components/animations/test-staggered-fade-and-slide.vue b/packages/_vue3-migration-test/src/components/animations/test-staggered-fade-and-slide.vue
new file mode 100644
index 0000000000..dadcd355f5
--- /dev/null
+++ b/packages/_vue3-migration-test/src/components/animations/test-staggered-fade-and-slide.vue
@@ -0,0 +1,68 @@
+
+ Dinamic content:
+
+
+
+
+
+ {{ item.id }} - {{ item.name }}
+
+
+
+
+
+ Animation as prop
+
+
+ {{ suggestion.query }}
+
+
+
+
+ Static content:
+
+ Element to animate
+ Element to animate
+ Element to animate
+
+
+
+
diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts
index c188737156..b6a8ec7597 100644
--- a/packages/_vue3-migration-test/src/router.ts
+++ b/packages/_vue3-migration-test/src/router.ts
@@ -49,7 +49,8 @@ import {
TestRenderlessExtraParam,
TestAnimationFactory,
TestIcons,
- TestDisplayEmitter
+ TestDisplayEmitter,
+ TestStaggeredFadeAndSlide
} from './';
const routes = [
@@ -302,6 +303,11 @@ const routes = [
path: '/display-emitter',
name: 'DisplayEmitter',
component: TestDisplayEmitter
+ },
+ {
+ path: '/staggered-fade-and-slide',
+ name: 'StaggeredFadeAndSlide',
+ component: TestStaggeredFadeAndSlide
}
];
diff --git a/packages/x-components/src/components/animations/staggered-fade-and-slide.vue b/packages/x-components/src/components/animations/staggered-fade-and-slide.vue
index bc2a484abd..86dc978b32 100644
--- a/packages/x-components/src/components/animations/staggered-fade-and-slide.vue
+++ b/packages/x-components/src/components/animations/staggered-fade-and-slide.vue
@@ -1,15 +1,19 @@
-
-
+
-
+
-
diff --git a/packages/x-components/src/components/base-grid.vue b/packages/x-components/src/components/base-grid.vue
index 86ed995de2..c89abc01ea 100644
--- a/packages/x-components/src/components/base-grid.vue
+++ b/packages/x-components/src/components/base-grid.vue
@@ -1,7 +1,6 @@
();
+ /**
+ * ResizeObserver instance to keep track of the number of columns rendered inside the grid.
+ */
+ let resizeObserver: { stop: () => void };
+
/**
* It injects {@link ListItem} provided by an ancestor.
*
@@ -124,9 +130,6 @@
undefined
);
- const gridEl = ref(null);
-
- let renderedColumnsNumber = ref(0);
/**
* Emits the {@link XEventsTypes.RenderedColumnsNumberChanged}
* event whenever the number of columns rendered inside the grid changes.
@@ -136,9 +139,7 @@
watch(
renderedColumnsNumber,
() => xBus.emit('RenderedColumnsNumberChanged', renderedColumnsNumber.value),
- {
- immediate: false
- }
+ { immediate: false }
);
/**
@@ -205,49 +206,38 @@
})
);
- /**
- * Checks if a given value is an `ElementRef` object.
- *
- * @param value - The value to check.
- * @returns `true` if the value is an `ElementRef` object, `false` otherwise.
- *
- * @internal
- */
- const isElementRef = (value: any): value is ElementRef => {
- return value && value.$el instanceof HTMLElement;
- };
-
/**
* Updates the number of columns rendered inside the grid.
- *
- * @internal
*/
const updateRenderedColumnsNumber = (): void => {
- const { gridTemplateColumns } = getComputedStyle(
- isElementRef(gridEl.value) ? gridEl.value.$el : (gridEl.value as Element)
- );
- renderedColumnsNumber.value = gridTemplateColumns.split(' ').length;
+ if (rootEl.value) {
+ const { gridTemplateColumns } = getComputedStyle(rootEl.value);
+ renderedColumnsNumber.value = gridTemplateColumns.split(' ').length;
+ }
};
/**
* Initialises the rendered columns number and sets a ResizeObserver to keep it updated.
- *
- * @internal
*/
- let resizeObserver: UseResizeObserverReturn;
onMounted(() => {
- resizeObserver = useResizeObserver(
- gridEl as MaybeComputedElementRef,
- updateRenderedColumnsNumber
- );
+ rootEl.value = getCurrentInstance()?.proxy?.$el as HTMLElement | undefined;
+ if (rootEl.value) {
+ resizeObserver = useResizeObserver(
+ rootEl as MaybeComputedElementRef,
+ updateRenderedColumnsNumber
+ );
+ }
});
+
+ /**
+ * Stops the ResizeObserver when the component is unmounted.
+ */
onBeforeUnmount(() => resizeObserver?.stop());
return {
gridItems,
cssClasses,
style,
- gridEl,
slots
};
}
diff --git a/packages/x-components/src/views/home/Home.vue b/packages/x-components/src/views/home/Home.vue
index 306700b313..1ff3881863 100644
--- a/packages/x-components/src/views/home/Home.vue
+++ b/packages/x-components/src/views/home/Home.vue
@@ -459,7 +459,7 @@
/* eslint-disable max-len */
import { computed, ComputedRef, defineComponent, provide } from 'vue';
// import { animateClipPath } from '../../components/animations/animate-clip-path/animate-clip-path.factory';
- // import StaggeredFadeAndSlide from '../../components/animations/staggered-fade-and-slide.vue';
+ import StaggeredFadeAndSlide from '../../components/animations/staggered-fade-and-slide.vue';
import AutoProgressBar from '../../components/auto-progress-bar.vue';
import BaseDropdown from '../../components/base-dropdown.vue';
import BaseGrid from '../../components/base-grid.vue';
@@ -586,6 +586,7 @@
SortPickerList,
Spellcheck,
SpellcheckButton,
+ StaggeredFadeAndSlide,
Tagging,
UrlHandler
},
@@ -600,7 +601,7 @@
'Find sunglasses'
];
const columnPickerValues = [0, 2, 4];
- // const resultsAnimation = StaggeredFadeAndSlide;
+ const resultsAnimation = StaggeredFadeAndSlide;
// const modalAnimation = animateClipPath();
const selectedColumns = 4;
const sortValues = ['', 'price asc', 'price desc'];
@@ -662,7 +663,7 @@
adapterConfig.e2e = !adapterConfig.e2e;
};
return {
- resultsAnimation: undefined,
+ resultsAnimation,
modalAnimation: undefined,
queriesPreviewInfo,
stores,