繁体   English   中英

KineticJS:使放置的元素作为Kinetic.Group可拖动

[英]KineticJS: make dropped elements be draggable as a Kinetic.Group

恩..所以这是我面对Kinetic.Group遇到的相同问题。 我尝试了几种方法来使它起作用,但结果始终是相同的:它不起作用,甚至更糟的是,基本的拖放功能也消失了!

我已经知道如何在一个容器中执行此操作,当我尝试使其适应从DOM到容器的拖放时,困难就来了。 放下后,我需要将图像和形状一起移动。 这就是为什么我为每个项目创建一个组并使其可拖动。

这是我正在更改的小提琴,用于在画布上放置放置的元素,可以作为一个整体拖动(非工作小提琴) http://jsfiddle.net/gkefk/15/ 此代码有什么问题?

PS1:这是我正在编辑的拖放http://jsfiddle.net/gkefk/14/的主要功能。

PS2:我是一个初学者,所以如果您在该代码中发现“愚蠢”,请报告。

一个简单的指南,说明如何从中获得所需的信息:

摆脱jQuery并重新开始。

1. Create a new Stage
2. Create two layers, one taking up the left half of the Stage, the other the right half.
3. put all your objects on the left side, make them clone-able on mousedown and fire the drag event so you can place them in the other layer on mouse up.
4. if your item is a rectangle - I'm assuming this is a group which is will have children, create a new group, and a rectangle inside it, place it in the right layer on drop.
5. if your item is a house, check for mouse intersection with a rectangle, if mouse is over a rectangle, get the parent of the rectangle on drop (which will be a group), and then place the house in that group, else place in right layer freely.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM