vue-slick icon indicating copy to clipboard operation
vue-slick copied to clipboard

Transition issue because of destroyed() hook

Open pschaub opened this issue 7 years ago • 8 comments

The slick will be "unslicked" on the destroyed hook. That results into a broken layout if the developer is using page transitions (e.g. on leaving a route). The reason behind this is that the unslick command will remove all slick classes and information from the DOM elements.

See also: https://github.com/vuejs/vue/issues/6983

There should be a way to wait for the transition to finish before unslick happens.

This can be easily reproduced with 2 pages and a very slow page route transition.

<transition name="route-transition-fade" mode="out-in">
    <router-view :key="$route.path"/>
</transition>
.route-transition-fade-enter-active, .route-transition-fade-leave-active {
  transition: opacity 500s ease;
}

.route-transition-fade-enter, .route-transition-fade-leave-to {
  opacity: 0;
}

pschaub avatar Mar 07 '18 08:03 pschaub

Has a solution for this been determined yet? Would love to continue using slick-slider with vue!

josephahern avatar Apr 02 '18 22:04 josephahern

Just faced this problem

ArkhipovK avatar May 31 '18 01:05 ArkhipovK

@ArkhipovK - I ended up doing something like this had to dig through commit history as we ended up not using slick in the end.

In slickCarousel.vue

destroyed() {
  const manualDestroy = () => {
  $(this.$el).slick('unslick');
    console.log('unslicked');
    this.$el.removeEventListener(manualDestroy);
  };
  this.$el.addEventListener('transitionend', manualDestroy);
},

radiantstatic avatar Jun 01 '18 03:06 radiantstatic

Doesn't help (( How to disable destroy method on transition?

khudia avatar Feb 08 '19 09:02 khudia

@khudia maybe check out https://github.com/diachedelic/vue-removed-hook-mixin

diachedelic avatar Apr 16 '19 01:04 diachedelic

@diachedelic I got an error because this.$options.removed is undefined

mnlauaa avatar Dec 13 '19 02:12 mnlauaa

@mnlauaa did you define a removed hook in your component? Check the example usage in the readme

diachedelic avatar Dec 15 '19 00:12 diachedelic

You can hide the slick after the animation starts. No slick - no problem.

.fade-leave-active {
  .--you-block-with-slick-- {
    opacity: 0;
    display: none;
  

NickolayBauer avatar Nov 12 '20 11:11 NickolayBauer