【发布时间】:2020-04-22 07:21:52
【问题描述】:
所以,我一直在使用 vue-konva,我有这样的东西:
<v-container>
<v-stage ref="stage">
<v-layer ref="baseImage">
<v-image>
</v-layer>
<v-layer ref="annotationLayer">
<v-rect ref="eventBox">
<v-rect ref="rubberBox">
<v-rect ref="annotationRect">
</v-layer>
</v-stage>
<v-container>
目前,如果我想绘制新框,当图像上已经有其他 annotationRects 时,会出现一些问题。因为它们在技术上位于 eventBox 和 Rubberbox 之上,所以当光标位于现有 annotationRect 之上时,它们会“阻挡”这两层。
但是,我不想总是让 eventBox 和 RubberBox 在 annotationRect 之上,因为我需要能够与 annotationRect 交互来移动它们、调整它们的大小等。
我有没有办法重新排序 eventBox、rubberBox 和 annotationRect,例如,将原始 eventBox-rubberBox-annotationRect 的顺序更改为(从下到上)annotationRect-eventBox-rubberBox 并返回,例如当 vue 组件接收到另一个组件的事件时?
【问题讨论】:
-
您可以为此使用 Konva z-index 属性。见konvajs.org/docs/groups_and_layers/zIndex.html。还有 shape.moveUp()、shape.moveDown、shape.moveToTop、shape.moveToBottom 函数,它们按照名称执行。所以 animationRect.moveToTop() 会把那个形状放在其他形状的“上方”。