Skip to content

[Help]: AutoHeight issue with WordPress blocks #998

Closed Answered by Micemade
Micemade asked this question in Help
Discussion options

You must be logged in to vote

Ok, I believe I solved this. This note from Embla Carousel Plugins docs page helped:

So, I used state management to trigger reInit() method when the Inner blocks are mounted, and added plugins to reInit argument:

// Trigger emblaApi.reInit method on data (innerblock mounted) received event.
const didInnerBlocksMount = useSelect((select) => select('micemade/data').didInnerBlocksMount());
useEffect(() => {
	if (didInnerBlocksMount && emblaApi) emblaApi.reInit(
		carouselOptions,
		[AutoHeight(), AutoPlay(autoplayOptions)]
	);
}, [didInnerBlocksMount, emblaApi]);

Hope this will help someone, or give an idea :)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Micemade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
resolved This issue is resolved question Question about how to achieve something
1 participant