Remove an element

Modified on Thu, 27 Jul 2023 at 12:41 PM

If you want to remove an element, e.g. before generating the product image, you can use the API of FPD first and then you can use the fabricjs API.


Using getElementByTitle method to return the fabricjs object: 

var fabricElement = thsirtDesigner.currentViewInstance.fabricCanvas.getElementByTitle('title-of-an-element');
console.log(fabricElement);

  

Now through the fabricElement variable you can use any method for that fabricjs object, e.g. the remove method. 

//wait until product is created
fpd.addEventListener('productCreate', function(){
thsirtDesigner.currentViewInstance.fabricCanvas.remove(fabricElement)

  //e.g. now you are able to generate an image without a specific element layer
  thsirtDesigner.getProductDataURL()
});

  

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article