Vue.draggable: make transitionMode as a prop

Created on 2 Apr 2018  路  3Comments  路  Source: SortableJS/Vue.Draggable

Currently this.transitionMode was hardcoded with the check that child.componentOptions.tag === "transition-group", but what if using a transition-group component (custom tag name) ?
Make it as a prop may solve the problem above.

Please check this commit: https://github.com/iou90/Vue.Draggable/commit/05399927c1985a8ae8a93a1ceec98ceddeccc6dc

All 3 comments

Hello, transitionMode is something like a private info that has to be acurate. While your commit will fix your problem, creating a prop will be error-prone as:
-having a transition-group with this props false will lead to unwanted behaviour
-setting props to true without transition-group will also result in a wrong behavior.

Maybe there are other way to compute transitionMode value.

@David-Desmaisons It's make sense, what about doing some detection in mounted?

var slots = this.$slots.default;
if (slots && slots.length === 1) {
  var child = slots[0];
  if (child.componentOptions && child.componentOptions.tag === "transition-group") {    
    this.transitionMode = true; 
  }
  if (child.componentInstance && child.componentInstance.$children && child.componentInstance.$children.length === 1) {
    var componentOfChild = child.componentInstance.$children[0];
    if(componentOfChild.$vnode && componentOfChild.$vnode.componentOptions && componentOfChild.$vnode.componentOptions.tag === "transition-group") {
      this.transitionMode = true;
    }
  }
}

Hello @iou90 , I am not sure that this functionality is woth the added complexity.
I prefer for now consider that transition are cirrently limted to "transition-group" component in vue.draggable.

Was this page helpful?
0 / 5 - 0 ratings