Raphael order objects

痴心易碎 提交于 2019-12-04 10:51:02

问题


I'm trying to order Raphael objects. I don't have the option of deciding when the objects are created, but I'd like to make a group of objects appear behind a group of other objects after they've been created. Can anybody help me do this?

Thanks.


回答1:


Group you items in two sets and position the sets relative to each other with insertBefore or insertAfter:

var front = paper.set();
front.push(front1, front2);

var back = paper.set();
back.push(back1, back2);

front.insertBefore(back);

Also if you have your items in arrays you can use apply for convenience:

var frontItems = [front1, front2];
front.push.apply(null, frontItems);



回答2:


You can use toBack. http://raphaeljs.com/reference.html#toBack

It will put an object behind the other objects regardless of when you created it.



来源:https://stackoverflow.com/questions/4393788/raphael-order-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!