clone() is not working for Path Object with the latest version of Fabricjs -
if fabric.path object cloned clone() method ,the path object not duplicated. have seen issue here https://github.com/kangax/fabric.js/issues/330 version of fabric js different. 1 please me on this.
var obj = canvas.getactiveobject(); if (!obj) return; var clone = obj.clone(); clone.set({ top: clone.get('top') + 150 }); canvas.add(clone); canvas.renderall();
below error getting.
else { fabric.util.enlivenobjects(object.paths, function(enlivenedobjects) { delete object.paths; callback(new fabric.pathgroup(enlivenedobjects, object)); ****uncaught typeerror: undefined not function**** }); } };
the above code working objects code not working path object
fabric.path
, fabric.pathgroup
object's async since fabric.js version 1.2.2 (https://github.com/kangax/fabric.js/commit/c8cab03aace5510554cd02fa143248ab7497f6c2).
so have differentiate between async , sync objects.
var obj = canvas.getactiveobject(); if (!obj) return; if (fabric.util.getklass(obj.type).async) { obj.clone(function (clone) { clone.set({left: 200, top: 100}); canvas.add(clone); }); } else { canvas.add(obj.clone().set({left: 100, top: 100})); }
here can see in action: http://jsfiddle.net/kienz/73cta/
Comments
Post a Comment