@bwp-web/canvas 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1836,10 +1836,11 @@ function enableDrawToCreate(canvas, options) {
1836
1836
  const finalize = () => {
1837
1837
  removePreviewElements();
1838
1838
  snapping.clearSnapResult();
1839
- const obj = options?.factory ? options.factory(canvas, [...points]) : createPolygonFromVertices(canvas, points, options?.style);
1840
- if (options?.data) {
1841
- obj.data = options.data;
1842
- }
1839
+ const styleWithData = {
1840
+ ...options?.style,
1841
+ ...options?.data != null && { data: options.data }
1842
+ };
1843
+ const obj = options?.factory ? options.factory(canvas, [...points]) : createPolygonFromVertices(canvas, points, styleWithData);
1843
1844
  canvas.selection = previousSelection;
1844
1845
  canvas.requestRenderAll();
1845
1846
  restoreViewport(options?.viewport);
@@ -1999,6 +2000,10 @@ function enableDrawToCreate(canvas, options) {
1999
2000
  placeVertex(dragStartX, dragStartY);
2000
2001
  return;
2001
2002
  }
2003
+ const dragStyleWithData = {
2004
+ ...options?.style,
2005
+ ...options?.data != null && { data: options.data }
2006
+ };
2002
2007
  const obj = createPolygonFromVertices(
2003
2008
  canvas,
2004
2009
  [
@@ -2007,11 +2012,8 @@ function enableDrawToCreate(canvas, options) {
2007
2012
  { x: dragStartX + width, y: dragStartY + height },
2008
2013
  { x: dragStartX, y: dragStartY + height }
2009
2014
  ],
2010
- options?.style
2015
+ dragStyleWithData
2011
2016
  );
2012
- if (options?.data) {
2013
- obj.data = options.data;
2014
- }
2015
2017
  canvas.selection = previousSelection;
2016
2018
  canvas.requestRenderAll();
2017
2019
  restoreViewport(options?.viewport);