How to update options after init in egjs-flicking?

14 Views Asked by At

I'm using egjs-flicking for Vue2 project. I want it to use different align option on mobile and desktop screen sizes. Is there a way to change without destroying/init?

1

There are 1 best solutions below

0
Alex Buznik On

Landed on the solution like this:

  1. Added on resize event handler with stores if it's a mobile screen in the component data, also two flags to understand its current size and if it has gone from mobile to desktop (or the other way around), and updating the Flicking options object to switch align.

  2. Using :key on the Flicking component to recreate it when it's gone from mobile to desktop (see flags above)

So after the window has gone from mobile to desktop or screen (or vice versa) the component is recreated without triggering destroy/init manually. Seems to suffice for now.