dist/vue-draggable-nested-tree.es.js
function autoMoveDragPlaceHolder(draggableHelperInfo) {
  var trees = this.store.trees;
  var dhStore = draggableHelperInfo.store; // make info

  var info = {
    event: draggableHelperInfo.event,
    el: dhStore.el,
    vm: this,
    node: this.data,
    store: this.store,
    dplh: this.store.dplh,
    draggableHelperData: {
      opt: draggableHelperInfo.options,
      store: dhStore
    } //

  };
  attachCache(info, new Cache(), {
    // dragging node coordinate
    // 拖动中的节点相关坐标
    nodeInnerEl: function nodeInnerEl() {
      return this.el.querySelector('.tree-node-inner');
    },
    offset: function offset() {
      return getOffset(this.nodeInnerEl);
    },
    // left top point
    offset2: function offset2() {
      return {
        x: this.offset.x + this.nodeInnerEl.offsetWidth,
        y: this.offset.y + this.nodeInnerEl.offsetHeight
      };
    },
    // right bottom point
    offsetToViewPort: function offsetToViewPort() {
      var r = this.nodeInnerEl.getBoundingClientRect();
      r.x = r.left;
      r.y = r.top;
      return r;
    },
    // tree
    currentTree: function currentTree() {
      // const currentTree = trees.find(tree => hp.isOffsetInEl(this.offset.x, this.offset.y, tree.$el))
      var currentTree = getTreeByPoint(this.offsetToViewPort.x, this.offsetToViewPort.y, trees);

      if (currentTree) {
        var dragStartTree = this.store;

        if (prevTree == null) {
          prevTree = dragStartTree;
        }

        if (prevTree !== currentTree) {
          if (!isPropTrue(dragStartTree.crossTree) || !isPropTrue(currentTree.crossTree)) {
            return;
          }

          prevTree = currentTree;
        }

        if (!isPropTrue(currentTree.droppable)) {
          return;
        }

        return currentTree;
      }
    },
    currentTreeRootEl: function currentTreeRootEl() {
      return document.getElementById(this.currentTree.rootData._id);
    },
    currentTreeRootOf4: function currentTreeRootOf4() {
      return getOf4(this.currentTreeRootEl, this.currentTree.space);
    },
    // the second child of currentTree root, excluding dragging node
    currentTreeRootSecondChildExcludingDragging: function currentTreeRootSecondChildExcludingDragging() {
      var _this = this;

      return this.currentTree.rootData.children.slice(0, 3).filter(function (v) {
        return v !== _this.node;
      })[1];
    },
    // placeholder
    dplhEl: function dplhEl() {
      return document.getElementById(this.dplh._id);
    },
    dplhElInCurrentTree: function dplhElInCurrentTree() {
      return Boolean(this.currentTree.$el.querySelector("#".concat(this.dplh._id)));
    },
    dplhOf4: function dplhOf4() {
      return getOf4(this.dplhEl, this.currentTree.space);
    },
    dplhAtTop: function dplhAtTop() {
      return Math.abs(this.dplhOf4.y - this.currentTreeRootOf4.y) < 5;
    },
    targetAtTop: function targetAtTop() {
      return Math.abs(this.tiOf4.y - this.currentTreeRootOf4.y) < 5;
    },
    targetAtBottom: function targetAtBottom() {
      return Math.abs(this.tiOf4.y2 - this.currentTreeRootOf4.y2) < 5;
    },
    // most related node
    // 最相关的另一个节点
    targetNode: function targetNode() {
      var currentTree = this.currentTree;

      if (!currentTree) {
        throw 'no currentTree';
      } //


      var _this$offset = this.offset,
          x = _this$offset.x,
          y = _this$offset.y;
      var currentNode = currentTree.rootData;

      while (true) {
        var children = currentNode.children;

        if (!children) {
          break;
        }

        if (this.node.parent === currentNode) {
          // dragging node is in currentNode children, remove it first
          children = children.slice();
          children.splice(children.indexOf(this.node), 1);
        }

        if (children.length === 0) {
          break;
        }

        var t = binarySearch(children, function (node) {
          var el = document.getElementById(node._id);
          var ty = getOffset(el).y;
          var ty2 = ty + el.offsetHeight + currentTree.space;

          if (ty2 < y) {
            return -1;
          } else if (ty <= y) {
            return 0;
          } else {
            return 1;
          }
        }, null, null, true);

        if (t.hit) {
          currentNode = t.value;
        } else {
          if (t.bigger) {
            currentNode = children[t.index - 1];
          } else {
            currentNode = t.value;
          }
        }

        if (!currentNode) {
          currentNode = children[0];
          break;
        }

        if (!currentNode) {
          break;
        }

        var innerEl = document.getElementById(currentNode._id).querySelector('.tree-node-inner');
        var of = getOf4(innerEl, currentTree.space);

        if (of.y <= y && y <= of.y2) {
          break;
        }
      }

      return currentNode;
    },
    targetNodeEl: function targetNodeEl() {
      return document.getElementById(this.targetNode._id);
    },
    // targetNodeInnerElOffset
    tiInnerEl: function tiInnerEl() {
      return this.targetNodeEl.querySelector('.tree-node-inner');
    },
    tiOffset: function tiOffset() {
      return getOffset(this.tiInnerEl);
    },
    tiOf4: function tiOf4() {
      return getOf4(this.tiInnerEl, this.currentTree.space);
    },
    tiMiddleY: function tiMiddleY() {
      return this.tiOffset.y + this.tiInnerEl.offsetHeight / 2;
    },
    //
    targetPrevEl: function targetPrevEl() {
      // tree node 之间不要有其他元素, 否则这里会获取到错误的元素
      var r = this.targetNodeEl.previousSibling;

      if (hasClass(r, 'dragging')) {
        r = r.previousSibling;
      }

      return r;
    },
    targetPrev: function targetPrev() {
      var id = this.targetPrevEl.getAttribute('id');
      return this.currentTree.getNodeById(id);
    }
  }); // attachCache end
  // decision start =================================

  var executedRuleCache = {}; // exec rule

  var exec = function exec(ruleId) {
    if (!executedRuleCache.hasOwnProperty(ruleId)) {
      var r;

      try {
        r = rules[ruleId](info);
      } catch (e) {
        r = e;

        try {
          if (process.env.DEVELOPE_SELF) {
            // only visible when develop its self
            console.warn("failed to execute rule '".concat(ruleId, "'"), e);
          }
        } catch (e2) {}
      }

      executedRuleCache[ruleId] = r;
    }

    return executedRuleCache[ruleId];
  };

  if (exec('currentTree existed') === true) {
    if (exec('targetNode is placeholder') === false) {
      if (exec('targetNode is the second child of root') === true) {
        if (exec('targetNode has children excluding placeholder') === false) {
          if (exec('on targetNode middle') === true) {
            targets['before'](info);
          } else if (exec('on targetNode middle') === false) {
            if (exec('at indent right') === true) {
              targets['append'](info);
            } else if (exec('at indent right') === false) {
              targets['after'](info);
            }
          }
        } else if (exec('targetNode has children excluding placeholder') === true) {
          targets['prepend'](info);
        }
      } else if (exec('targetNode is the second child of root') === false) {
        if (exec('currentTree empty') === false) {
          if (exec('targetNode at top') === true) {
            if (exec('placeholder in currentTree') === true) {
              if (exec('targetNode has children excluding placeholder') === false) {
                if (exec('on targetNode middle') === false) {
                  if (exec('at indent right') === false) {
                    targets['after'](info);
                  } else if (exec('at indent right') === true) {
                    targets['append'](info);
                  }
                } else if (exec('on targetNode middle') === true) {
                  targets['before'](info);
                }
              } else if (exec('targetNode has children excluding placeholder') === true) {
                if (exec('on targetNode middle') === false) {
                  targets['prepend'](info);
                } else if (exec('on targetNode middle') === true) {
                  targets['before'](info);
                }
              }
            } else if (exec('placeholder in currentTree') === false) {
              targets['before'](info);
            }
          } else if (exec('targetNode at top') === false) {
            if (exec('targetNode at bottom') === false) {
              if (exec('placeholder at top') === true) {
                targets['prepend'](info);
              } else if (exec('placeholder at top') === false) {
                if (exec('targetNode has children excluding placeholder') === true) {
                  targets['prepend'](info);
                } else if (exec('targetNode has children excluding placeholder') === false) {
                  if (exec('targetNode is 1st child') === false) {
                    if (exec('targetNode is last child') === false) {
                      if (exec('on targetNode middle') === true) {
                        if (exec('at indent right') === true) {
                          targets['append'](info);
                        } else if (exec('at indent right') === false) {
                          targets['after'](info);
                        }
                      } else if (exec('on targetNode middle') === false) {
                        if (exec('at indent right') === true) {
                          targets['append'](info);
                        } else if (exec('at indent right') === false) {
                          targets['after'](info);
                        }
                      }
                    } else if (exec('targetNode is last child') === true) {
                      if (exec('at indent right') === true) {
                        targets['append'](info);
                      } else if (exec('at indent right') === false) {
                        targets['after'](info);
                      }
                    }
                  } else if (exec('targetNode is 1st child') === true) {
                    if (exec('targetNode is last child') === true) {
                      targets['append'](info);
                    } else if (exec('targetNode is last child') === false) {
                      if (exec('on targetNode middle') === false) {
                        if (exec('at indent right') === false) {
                          targets['after'](info);
                        } else if (exec('at indent right') === true) {
                          targets['append'](info);
                        }
                      } else if (exec('on targetNode middle') === true) {
                        if (exec('at indent right') === false) {
                          targets['after'](info);
                        } else if (exec('at indent right') === true) {
                          targets['append'](info);
                        }
                      }
                    }
                  }
                }
              }
            } else if (exec('targetNode at bottom') === true) {
              if (exec('placeholder in currentTree') === true) {
                if (exec('on targetNode middle') === false) {
                  if (exec('at indent right') === true) {
                    targets['append'](info);
                  } else if (exec('at indent right') === false) {
                    targets['after'](info);
                  }
                } else if (exec('on targetNode middle') === true) {
                  targets['append'](info);
                }
              } else if (exec('placeholder in currentTree') === false) {
                targets['append'](info);
              }
            }
          }
        } else if (exec('currentTree empty') === true) {
          targets['append current tree'](info);
        }
      }
    } else if (exec('targetNode is placeholder') === true) {
      if (exec('targetNode at bottom') === false) {
        if (exec('targetNode is the second child of root') === false) {
          if (exec('targetNode is 1st child') === true) {
            if (exec('targetNode is last child') === false) ; else if (exec('targetNode is last child') === true) {
              if (exec('on targetNode middle') === false) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) ;
              } else if (exec('on targetNode middle') === true) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) ;
              }
            }
          } else if (exec('targetNode is 1st child') === false) {
            if (exec('targetNode is last child') === true) {
              if (exec('on targetNode middle') === true) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              } else if (exec('on targetNode middle') === false) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              }
            } else if (exec('targetNode is last child') === false) {
              if (exec('on targetNode middle') === true) {
                if (exec('at left') === true) ; else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              } else if (exec('on targetNode middle') === false) {
                if (exec('at left') === true) ; else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              }
            }
          }
        } else if (exec('targetNode is the second child of root') === true) {
          if (exec('on targetNode middle') === true) {
            if (exec('at indent right') === true) {
              targets['append prev'](info);
            } else if (exec('at indent right') === false) ;
          } else if (exec('on targetNode middle') === false) {
            if (exec('at indent right') === true) {
              targets['append prev'](info);
            } else if (exec('at indent right') === false) ;
          }
        }
      } else if (exec('targetNode at bottom') === true) {
        if (exec('targetNode is 1st child') === true) {
          if (exec('on targetNode middle') === false) {
            if (exec('at left') === true) {
              targets['after target parent'](info);
            } else if (exec('at left') === false) ;
          } else if (exec('on targetNode middle') === true) {
            if (exec('at left') === false) ; else if (exec('at left') === true) {
              targets['after target parent'](info);
            }
          }
        } else if (exec('targetNode is 1st child') === false) {
          if (exec('on targetNode middle') === false) {
            if (exec('at left') === true) {
              targets['after target parent'](info);
            } else if (exec('at left') === false) {
              if (exec('at indent right') === true) {
                targets['append prev'](info);
              } else if (exec('at indent right') === false) ;
            }
          } else if (exec('on targetNode middle') === true) {
            if (exec('at left') === true) {
              targets['after target parent'](info);
            } else if (exec('at left') === false) {
              if (exec('at indent right') === true) {
                targets['append prev'](info);
              } else if (exec('at indent right') === false) ;
            }
          }
        }
      }
    }
  } else if (exec('currentTree existed') === false) ; // decision end =================================
  //

}
function autoMoveDragPlaceHolder(draggableHelperInfo) {
  var trees = this.store.trees;
  var dhStore = draggableHelperInfo.store; // make info

  var info = {
    event: draggableHelperInfo.event,
    el: dhStore.el,
    vm: this,
    node: this.data,
    store: this.store,
    dplh: this.store.dplh,
    draggableHelperData: {
      opt: draggableHelperInfo.options,
      store: dhStore
    } //

  };
  attachCache(info, new Cache(), {
    // dragging node coordinate
    // 拖动中的节点相关坐标
    nodeInnerEl: function nodeInnerEl() {
      return this.el.querySelector('.tree-node-inner');
    },
    offset: function offset() {
      return getOffset(this.nodeInnerEl);
    },
    // left top point
    offset2: function offset2() {
      return {
        x: this.offset.x + this.nodeInnerEl.offsetWidth,
        y: this.offset.y + this.nodeInnerEl.offsetHeight
      };
    },
    // right bottom point
    offsetToViewPort: function offsetToViewPort() {
      var r = this.nodeInnerEl.getBoundingClientRect();
      r.x = r.left;
      r.y = r.top;
      return r;
    },
    // tree
    currentTree: function currentTree() {
      // const currentTree = trees.find(tree => hp.isOffsetInEl(this.offset.x, this.offset.y, tree.$el))
      var currentTree = getTreeByPoint(this.offsetToViewPort.x, this.offsetToViewPort.y, trees);

      if (currentTree) {
        var dragStartTree = this.store;

        if (prevTree == null) {
          prevTree = dragStartTree;
        }

        if (prevTree !== currentTree) {
          if (!isPropTrue(dragStartTree.crossTree) || !isPropTrue(currentTree.crossTree)) {
            return;
          }

          prevTree = currentTree;
        }

        if (!isPropTrue(currentTree.droppable)) {
          return;
        }

        return currentTree;
      }
    },
    currentTreeRootEl: function currentTreeRootEl() {
      return document.getElementById(this.currentTree.rootData._id);
    },
    currentTreeRootOf4: function currentTreeRootOf4() {
      return getOf4(this.currentTreeRootEl, this.currentTree.space);
    },
    // the second child of currentTree root, excluding dragging node
    currentTreeRootSecondChildExcludingDragging: function currentTreeRootSecondChildExcludingDragging() {
      var _this = this;

      return this.currentTree.rootData.children.slice(0, 3).filter(function (v) {
        return v !== _this.node;
      })[1];
    },
    // placeholder
    dplhEl: function dplhEl() {
      return document.getElementById(this.dplh._id);
    },
    dplhElInCurrentTree: function dplhElInCurrentTree() {
      return Boolean(this.currentTree.$el.querySelector("#".concat(this.dplh._id)));
    },
    dplhOf4: function dplhOf4() {
      return getOf4(this.dplhEl, this.currentTree.space);
    },
    dplhAtTop: function dplhAtTop() {
      return Math.abs(this.dplhOf4.y - this.currentTreeRootOf4.y) < 5;
    },
    targetAtTop: function targetAtTop() {
      return Math.abs(this.tiOf4.y - this.currentTreeRootOf4.y) < 5;
    },
    targetAtBottom: function targetAtBottom() {
      return Math.abs(this.tiOf4.y2 - this.currentTreeRootOf4.y2) < 5;
    },
    // most related node
    // 最相关的另一个节点
    targetNode: function targetNode() {
      var currentTree = this.currentTree;

      if (!currentTree) {
        throw 'no currentTree';
      } //


      var _this$offset = this.offset,
          x = _this$offset.x,
          y = _this$offset.y;
      var currentNode = currentTree.rootData;

      while (true) {
        var children = currentNode.children;

        if (!children) {
          break;
        }

        if (this.node.parent === currentNode) {
          // dragging node is in currentNode children, remove it first
          children = children.slice();
          children.splice(children.indexOf(this.node), 1);
        }

        if (children.length === 0) {
          break;
        }

        var t = binarySearch(children, function (node) {
          var el = document.getElementById(node._id);
          var ty = getOffset(el).y;
          var ty2 = ty + el.offsetHeight + currentTree.space;

          if (ty2 < y) {
            return -1;
          } else if (ty <= y) {
            return 0;
          } else {
            return 1;
          }
        }, null, null, true);

        if (t.hit) {
          currentNode = t.value;
        } else {
          if (t.bigger) {
            currentNode = children[t.index - 1];
          } else {
            currentNode = t.value;
          }
        }

        if (!currentNode) {
          currentNode = children[0];
          break;
        }

        if (!currentNode) {
          break;
        }

        var innerEl = document.getElementById(currentNode._id).querySelector('.tree-node-inner');
        var of = getOf4(innerEl, currentTree.space);

        if (of.y <= y && y <= of.y2) {
          break;
        }
      }

      return currentNode;
    },
    targetNodeEl: function targetNodeEl() {
      return document.getElementById(this.targetNode._id);
    },
    // targetNodeInnerElOffset
    tiInnerEl: function tiInnerEl() {
      return this.targetNodeEl.querySelector('.tree-node-inner');
    },
    tiOffset: function tiOffset() {
      return getOffset(this.tiInnerEl);
    },
    tiOf4: function tiOf4() {
      return getOf4(this.tiInnerEl, this.currentTree.space);
    },
    tiMiddleY: function tiMiddleY() {
      return this.tiOffset.y + this.tiInnerEl.offsetHeight / 2;
    },
    //
    targetPrevEl: function targetPrevEl() {
      // tree node 之间不要有其他元素, 否则这里会获取到错误的元素
      var r = this.targetNodeEl.previousSibling;

      if (hasClass(r, 'dragging')) {
        r = r.previousSibling;
      }

      return r;
    },
    targetPrev: function targetPrev() {
      var id = this.targetPrevEl.getAttribute('id');
      return this.currentTree.getNodeById(id);
    }
  }); // attachCache end
  // decision start =================================

  var executedRuleCache = {}; // exec rule

  var exec = function exec(ruleId) {
    if (!executedRuleCache.hasOwnProperty(ruleId)) {
      var r;

      try {
        r = rules[ruleId](info);
      } catch (e) {
        r = e;

        try {
          if (process.env.DEVELOPE_SELF) {
            // only visible when develop its self
            console.warn("failed to execute rule '".concat(ruleId, "'"), e);
          }
        } catch (e2) {}
      }

      executedRuleCache[ruleId] = r;
    }

    return executedRuleCache[ruleId];
  };

  if (exec('currentTree existed') === true) {
    if (exec('targetNode is placeholder') === false) {
      if (exec('targetNode is the second child of root') === true) {
        if (exec('targetNode has children excluding placeholder') === false) {
          if (exec('on targetNode middle') === true) {
            targets['before'](info);
          } else if (exec('on targetNode middle') === false) {
            if (exec('at indent right') === true) {
              targets['append'](info);
            } else if (exec('at indent right') === false) {
              targets['after'](info);
            }
          }
        } else if (exec('targetNode has children excluding placeholder') === true) {
          targets['prepend'](info);
        }
      } else if (exec('targetNode is the second child of root') === false) {
        if (exec('currentTree empty') === false) {
          if (exec('targetNode at top') === true) {
            if (exec('placeholder in currentTree') === true) {
              if (exec('targetNode has children excluding placeholder') === false) {
                if (exec('on targetNode middle') === false) {
                  if (exec('at indent right') === false) {
                    targets['after'](info);
                  } else if (exec('at indent right') === true) {
                    targets['append'](info);
                  }
                } else if (exec('on targetNode middle') === true) {
                  targets['before'](info);
                }
              } else if (exec('targetNode has children excluding placeholder') === true) {
                if (exec('on targetNode middle') === false) {
                  targets['prepend'](info);
                } else if (exec('on targetNode middle') === true) {
                  targets['before'](info);
                }
              }
            } else if (exec('placeholder in currentTree') === false) {
              targets['before'](info);
            }
          } else if (exec('targetNode at top') === false) {
            if (exec('targetNode at bottom') === false) {
              if (exec('placeholder at top') === true) {
                targets['prepend'](info);
              } else if (exec('placeholder at top') === false) {
                if (exec('targetNode has children excluding placeholder') === true) {
                  targets['prepend'](info);
                } else if (exec('targetNode has children excluding placeholder') === false) {
                  if (exec('targetNode is 1st child') === false) {
                    if (exec('targetNode is last child') === false) {
                      if (exec('on targetNode middle') === true) {
                        if (exec('at indent right') === true) {
                          targets['append'](info);
                        } else if (exec('at indent right') === false) {
                          targets['after'](info);
                        }
                      } else if (exec('on targetNode middle') === false) {
                        if (exec('at indent right') === true) {
                          targets['append'](info);
                        } else if (exec('at indent right') === false) {
                          targets['after'](info);
                        }
                      }
                    } else if (exec('targetNode is last child') === true) {
                      if (exec('at indent right') === true) {
                        targets['append'](info);
                      } else if (exec('at indent right') === false) {
                        targets['after'](info);
                      }
                    }
                  } else if (exec('targetNode is 1st child') === true) {
                    if (exec('targetNode is last child') === true) {
                      targets['append'](info);
                    } else if (exec('targetNode is last child') === false) {
                      if (exec('on targetNode middle') === false) {
                        if (exec('at indent right') === false) {
                          targets['after'](info);
                        } else if (exec('at indent right') === true) {
                          targets['append'](info);
                        }
                      } else if (exec('on targetNode middle') === true) {
                        if (exec('at indent right') === false) {
                          targets['after'](info);
                        } else if (exec('at indent right') === true) {
                          targets['append'](info);
                        }
                      }
                    }
                  }
                }
              }
            } else if (exec('targetNode at bottom') === true) {
              if (exec('placeholder in currentTree') === true) {
                if (exec('on targetNode middle') === false) {
                  if (exec('at indent right') === true) {
                    targets['append'](info);
                  } else if (exec('at indent right') === false) {
                    targets['after'](info);
                  }
                } else if (exec('on targetNode middle') === true) {
                  targets['append'](info);
                }
              } else if (exec('placeholder in currentTree') === false) {
                targets['append'](info);
              }
            }
          }
        } else if (exec('currentTree empty') === true) {
          targets['append current tree'](info);
        }
      }
    } else if (exec('targetNode is placeholder') === true) {
      if (exec('targetNode at bottom') === false) {
        if (exec('targetNode is the second child of root') === false) {
          if (exec('targetNode is 1st child') === true) {
            if (exec('targetNode is last child') === false) ; else if (exec('targetNode is last child') === true) {
              if (exec('on targetNode middle') === false) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) ;
              } else if (exec('on targetNode middle') === true) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) ;
              }
            }
          } else if (exec('targetNode is 1st child') === false) {
            if (exec('targetNode is last child') === true) {
              if (exec('on targetNode middle') === true) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              } else if (exec('on targetNode middle') === false) {
                if (exec('at left') === true) {
                  targets['after target parent'](info);
                } else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              }
            } else if (exec('targetNode is last child') === false) {
              if (exec('on targetNode middle') === true) {
                if (exec('at left') === true) ; else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              } else if (exec('on targetNode middle') === false) {
                if (exec('at left') === true) ; else if (exec('at left') === false) {
                  if (exec('at indent right') === true) {
                    targets['append prev'](info);
                  } else if (exec('at indent right') === false) ;
                }
              }
            }
          }
        } else if (exec('targetNode is the second child of root') === true) {
          if (exec('on targetNode middle') === true) {
            if (exec('at indent right') === true) {
              targets['append prev'](info);
            } else if (exec('at indent right') === false) ;
          } else if (exec('on targetNode middle') === false) {
            if (exec('at indent right') === true) {
              targets['append prev'](info);
            } else if (exec('at indent right') === false) ;
          }
        }
      } else if (exec('targetNode at bottom') === true) {
        if (exec('targetNode is 1st child') === true) {
          if (exec('on targetNode middle') === false) {
            if (exec('at left') === true) {
              targets['after target parent'](info);
            } else if (exec('at left') === false) ;
          } else if (exec('on targetNode middle') === true) {
            if (exec('at left') === false) ; else if (exec('at left') === true) {
              targets['after target parent'](info);
            }
          }
        } else if (exec('targetNode is 1st child') === false) {
          if (exec('on targetNode middle') === false) {
            if (exec('at left') === true) {
              targets['after target parent'](info);
            } else if (exec('at left') === false) {
              if (exec('at indent right') === true) {
                targets['append prev'](info);
              } else if (exec('at indent right') === false) ;
            }
          } else if (exec('on targetNode middle') === true) {
            if (exec('at left') === true) {
              targets['after target parent'](info);
            } else if (exec('at left') === false) {
              if (exec('at indent right') === true) {
                targets['append prev'](info);
              } else if (exec('at indent right') === false) ;
            }
          }
        }
      }
    }
  } else if (exec('currentTree existed') === false) ; // decision end =================================
  //

}
function autoMoveDragPlaceHolder ( draggableHelperInfo ) { var trees = this . store . trees ; var dhStore = draggableHelperInfo . store ; // make info var info = { event : draggableHelperInfo . event , el : dhStore . el , vm : this , node : this . data , store : this . store , dplh : this . store . dplh , draggableHelperData : { opt : draggableHelperInfo . options , store : dhStore } // } ; attachCache ( info , new Cache ( ) , { // dragging node coordinate // 拖动中的节点相关坐标 nodeInnerEl : function nodeInnerEl ( ) { return this . el . querySelector ( '.tree-node-inner' ) ; } , offset : function offset ( ) { return getOffset ( this . nodeInnerEl ) ; } , // left top point offset2 : function offset2 ( ) { return { x : this . offset . x + this . nodeInnerEl . offsetWidth , y : this . offset . y + this . nodeInnerEl . offsetHeight } ; } , // right bottom point offsetToViewPort : function offsetToViewPort ( ) { var r = this . nodeInnerEl . getBoundingClientRect ( ) ; r . x = r . left ; r . y = r . top ; return r ; } , // tree currentTree : function currentTree ( ) { // const currentTree = trees.find(tree => hp.isOffsetInEl(this.offset.x, this.offset.y, tree.$el)) var currentTree = getTreeByPoint ( this . offsetToViewPort . x , this . offsetToViewPort . y , trees ) ; if ( currentTree ) { var dragStartTree = this . store ; if ( prevTree == null ) { prevTree = dragStartTree ; } if ( prevTree !== currentTree ) { if ( ! isPropTrue ( dragStartTree . crossTree ) || ! isPropTrue ( currentTree . crossTree ) ) { return ; } prevTree = currentTree ; } if ( ! isPropTrue ( currentTree . droppable ) ) { return ; } return currentTree ; } } , currentTreeRootEl : function currentTreeRootEl ( ) { return document . getElementById ( this . currentTree . rootData . _id ) ; } , currentTreeRootOf4 : function currentTreeRootOf4 ( ) { return getOf4 ( this . currentTreeRootEl , this . currentTree . space ) ; } , // the second child of currentTree root, excluding dragging node currentTreeRootSecondChildExcludingDragging : function currentTreeRootSecondChildExcludingDragging ( ) { var _this = this ; return this . currentTree . rootData . children . slice ( 0 , 3 ) . filter ( function ( v ) { return v !== _this . node ; } ) [ 1 ] ; } , // placeholder dplhEl : function dplhEl ( ) { return document . getElementById ( this . dplh . _id ) ; } , dplhElInCurrentTree : function dplhElInCurrentTree ( ) { return Boolean ( this . currentTree . $el . querySelector ( "#" . concat ( this . dplh . _id ) ) ) ; } , dplhOf4 : function dplhOf4 ( ) { return getOf4 ( this . dplhEl , this . currentTree . space ) ; } , dplhAtTop : function dplhAtTop ( ) { return Math . abs ( this . dplhOf4 . y - this . currentTreeRootOf4 . y ) < 5 ; } , targetAtTop : function targetAtTop ( ) { return Math . abs ( this . tiOf4 . y - this . currentTreeRootOf4 . y ) < 5 ; } , targetAtBottom : function targetAtBottom ( ) { return Math . abs ( this . tiOf4 . y2 - this . currentTreeRootOf4 . y2 ) < 5 ; } , // most related node // 最相关的另一个节点 targetNode : function targetNode ( ) { var currentTree = this . currentTree ; if ( ! currentTree ) { throw 'no currentTree' ; } // var _this$offset = this . offset , x = _this$offset . x , y = _this$offset . y ; var currentNode = currentTree . rootData ; while ( true ) { var children = currentNode . children ; if ( ! children ) { break ; } if ( this . node . parent === currentNode ) { // dragging node is in currentNode children, remove it first children = children . slice ( ) ; children . splice ( children . indexOf ( this . node ) , 1 ) ; } if ( children . length === 0 ) { break ; } var t = binarySearch ( children , function ( node ) { var el = document . getElementById ( node . _id ) ; var ty = getOffset ( el ) . y ; var ty2 = ty + el . offsetHeight + currentTree . space ; if ( ty2 < y ) { return - 1 ; } else if ( ty <= y ) { return 0 ; } else { return 1 ; } } , null , null , true ) ; if ( t . hit ) { currentNode = t . value ; } else { if ( t . bigger ) { currentNode = children [ t . index - 1 ] ; } else { currentNode = t . value ; } } if ( ! currentNode ) { currentNode = children [ 0 ] ; break ; } if ( ! currentNode ) { break ; } var innerEl = document . getElementById ( currentNode . _id ) . querySelector ( '.tree-node-inner' ) ; var of = getOf4 ( innerEl , currentTree . space ) ; if ( of . y <= y && y <= of . y2 ) { break ; } } return currentNode ; } , targetNodeEl : function targetNodeEl ( ) { return document . getElementById ( this . targetNode . _id ) ; } , // targetNodeInnerElOffset tiInnerEl : function tiInnerEl ( ) { return this . targetNodeEl . querySelector ( '.tree-node-inner' ) ; } , tiOffset : function tiOffset ( ) { return getOffset ( this . tiInnerEl ) ; } , tiOf4 : function tiOf4 ( ) { return getOf4 ( this . tiInnerEl , this . currentTree . space ) ; } , tiMiddleY : function tiMiddleY ( ) { return this . tiOffset . y + this . tiInnerEl . offsetHeight / 2 ; } , // targetPrevEl : function targetPrevEl ( ) { // tree node 之间不要有其他元素, 否则这里会获取到错误的元素 var r = this . targetNodeEl . previousSibling ; if ( hasClass ( r , 'dragging' ) ) { r = r . previousSibling ; } return r ; } , targetPrev : function targetPrev ( ) { var id = this . targetPrevEl . getAttribute ( 'id' ) ; return this . currentTree . getNodeById ( id ) ; } } ) ; // attachCache end // decision start ================================= var executedRuleCache = { } ; // exec rule var exec = function exec ( ruleId ) { if ( ! executedRuleCache . hasOwnProperty ( ruleId ) ) { var r ; try { r = rules [ ruleId ] ( info ) ; } catch ( e ) { r = e ; try { if ( process . env . DEVELOPE_SELF ) { // only visible when develop its self console . warn ( "failed to execute rule '" . concat ( ruleId , "'" ) , e ) ; } } catch ( e2 ) { } } executedRuleCache [ ruleId ] = r ; } return executedRuleCache [ ruleId ] ; } ; if ( exec ( 'currentTree existed' ) === true ) { if ( exec ( 'targetNode is placeholder' ) === false ) { if ( exec ( 'targetNode is the second child of root' ) === true ) { if ( exec ( 'targetNode has children excluding placeholder' ) === false ) { if ( exec ( 'on targetNode middle' ) === true ) { targets [ 'before' ] ( info ) ; } else if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } } } else if ( exec ( 'targetNode has children excluding placeholder' ) === true ) { targets [ 'prepend' ] ( info ) ; } } else if ( exec ( 'targetNode is the second child of root' ) === false ) { if ( exec ( 'currentTree empty' ) === false ) { if ( exec ( 'targetNode at top' ) === true ) { if ( exec ( 'placeholder in currentTree' ) === true ) { if ( exec ( 'targetNode has children excluding placeholder' ) === false ) { if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } else if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } } else if ( exec ( 'on targetNode middle' ) === true ) { targets [ 'before' ] ( info ) ; } } else if ( exec ( 'targetNode has children excluding placeholder' ) === true ) { if ( exec ( 'on targetNode middle' ) === false ) { targets [ 'prepend' ] ( info ) ; } else if ( exec ( 'on targetNode middle' ) === true ) { targets [ 'before' ] ( info ) ; } } } else if ( exec ( 'placeholder in currentTree' ) === false ) { targets [ 'before' ] ( info ) ; } } else if ( exec ( 'targetNode at top' ) === false ) { if ( exec ( 'targetNode at bottom' ) === false ) { if ( exec ( 'placeholder at top' ) === true ) { targets [ 'prepend' ] ( info ) ; } else if ( exec ( 'placeholder at top' ) === false ) { if ( exec ( 'targetNode has children excluding placeholder' ) === true ) { targets [ 'prepend' ] ( info ) ; } else if ( exec ( 'targetNode has children excluding placeholder' ) === false ) { if ( exec ( 'targetNode is 1st child' ) === false ) { if ( exec ( 'targetNode is last child' ) === false ) { if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } } else if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } } } else if ( exec ( 'targetNode is last child' ) === true ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } } } else if ( exec ( 'targetNode is 1st child' ) === true ) { if ( exec ( 'targetNode is last child' ) === true ) { targets [ 'append' ] ( info ) ; } else if ( exec ( 'targetNode is last child' ) === false ) { if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } else if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } } else if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } else if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } } } } } } } else if ( exec ( 'targetNode at bottom' ) === true ) { if ( exec ( 'placeholder in currentTree' ) === true ) { if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) { targets [ 'after' ] ( info ) ; } } else if ( exec ( 'on targetNode middle' ) === true ) { targets [ 'append' ] ( info ) ; } } else if ( exec ( 'placeholder in currentTree' ) === false ) { targets [ 'append' ] ( info ) ; } } } } else if ( exec ( 'currentTree empty' ) === true ) { targets [ 'append current tree' ] ( info ) ; } } } else if ( exec ( 'targetNode is placeholder' ) === true ) { if ( exec ( 'targetNode at bottom' ) === false ) { if ( exec ( 'targetNode is the second child of root' ) === false ) { if ( exec ( 'targetNode is 1st child' ) === true ) { if ( exec ( 'targetNode is last child' ) === false ) ; else if ( exec ( 'targetNode is last child' ) === true ) { if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) ; } else if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) ; } } } else if ( exec ( 'targetNode is 1st child' ) === false ) { if ( exec ( 'targetNode is last child' ) === true ) { if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } else if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } } else if ( exec ( 'targetNode is last child' ) === false ) { if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at left' ) === true ) ; else if ( exec ( 'at left' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } else if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at left' ) === true ) ; else if ( exec ( 'at left' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } } } } else if ( exec ( 'targetNode is the second child of root' ) === true ) { if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } else if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } } else if ( exec ( 'targetNode at bottom' ) === true ) { if ( exec ( 'targetNode is 1st child' ) === true ) { if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) ; } else if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at left' ) === false ) ; else if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } } } else if ( exec ( 'targetNode is 1st child' ) === false ) { if ( exec ( 'on targetNode middle' ) === false ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } else if ( exec ( 'on targetNode middle' ) === true ) { if ( exec ( 'at left' ) === true ) { targets [ 'after target parent' ] ( info ) ; } else if ( exec ( 'at left' ) === false ) { if ( exec ( 'at indent right' ) === true ) { targets [ 'append prev' ] ( info ) ; } else if ( exec ( 'at indent right' ) === false ) ; } } } } } } else if ( exec ( 'currentTree existed' ) === false ) ; // decision end ================================= // }
context is vm
context is vm