kitchen-simulator 4.0.6 → 4.0.7-measurement-unit-payload

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.
Files changed (47) hide show
  1. package/es/actions/project-actions.js +2 -1
  2. package/es/catalog/factories/wall-factory.js +1 -1
  3. package/es/catalog/utils/exporter.js +23 -11
  4. package/es/catalog/utils/item-loader.js +4 -9
  5. package/es/class/item.js +3 -0
  6. package/es/class/layer.js +1 -1
  7. package/es/class/project.js +9 -7
  8. package/es/components/viewer2d/line.js +5 -5
  9. package/es/components/viewer2d/ruler.js +16 -13
  10. package/es/components/viewer2d/rulerDist.js +38 -52
  11. package/es/components/viewer2d/viewer2d.js +10 -5
  12. package/es/components/viewer3d/scene-creator.js +213 -53
  13. package/es/components/viewer3d/viewer3d.js +21 -14
  14. package/es/constants.js +1 -0
  15. package/es/index.js +26 -5
  16. package/es/models.js +10 -6
  17. package/es/reducers/project-reducer.js +1 -1
  18. package/es/reducers/viewer2d-reducer.js +3 -1
  19. package/es/reducers/viewer3d-reducer.js +3 -1
  20. package/es/utils/geometry.js +7 -7
  21. package/es/utils/isolate-event-handler.js +8 -8
  22. package/es/utils/molding.js +4 -2
  23. package/es/utils/ruler.js +58 -0
  24. package/lib/actions/project-actions.js +2 -1
  25. package/lib/catalog/factories/wall-factory.js +1 -1
  26. package/lib/catalog/utils/exporter.js +23 -11
  27. package/lib/catalog/utils/item-loader.js +4 -9
  28. package/lib/class/item.js +3 -0
  29. package/lib/class/layer.js +1 -1
  30. package/lib/class/project.js +9 -7
  31. package/lib/components/viewer2d/line.js +5 -5
  32. package/lib/components/viewer2d/ruler.js +15 -12
  33. package/lib/components/viewer2d/rulerDist.js +38 -52
  34. package/lib/components/viewer2d/viewer2d.js +10 -5
  35. package/lib/components/viewer3d/scene-creator.js +212 -52
  36. package/lib/components/viewer3d/viewer3d.js +21 -14
  37. package/lib/constants.js +5 -4
  38. package/lib/index.js +28 -5
  39. package/lib/models.js +10 -6
  40. package/lib/reducers/project-reducer.js +1 -1
  41. package/lib/reducers/viewer2d-reducer.js +3 -1
  42. package/lib/reducers/viewer3d-reducer.js +3 -1
  43. package/lib/utils/geometry.js +7 -7
  44. package/lib/utils/isolate-event-handler.js +8 -8
  45. package/lib/utils/molding.js +4 -2
  46. package/lib/utils/ruler.js +63 -0
  47. package/package.json +1 -1
@@ -286,11 +286,12 @@ export function selectAll() {
286
286
  value: value
287
287
  };
288
288
  }
289
- export function createRoomWithShape(roomShapeType, width, height, doorStyle) {
289
+ export function createRoomWithShape(roomShapeType, width, height, measurementUnit, doorStyle) {
290
290
  return {
291
291
  type: CREATE_ROOM_WITH_SHAPE,
292
292
  width: width,
293
293
  height: height,
294
+ measurementUnit: measurementUnit,
294
295
  roomShapeType: roomShapeType,
295
296
  doorStyle: doorStyle
296
297
  };
@@ -16,7 +16,7 @@ var STYLE_LINE = {
16
16
  // strokeWidth:1
17
17
  };
18
18
  var STYLE_INTERIOR_LINE = {
19
- strokeWidth: 2,
19
+ strokeWidth: 4,
20
20
  stroke: SharedStyle.INTERIOR_LINE.unselected
21
21
  };
22
22
  var STYLE_INTERIOR_LINE_SELECTED = {
@@ -20,9 +20,18 @@ export default function (_ref) {
20
20
  alti = _ref.alti,
21
21
  obj_property = _ref.obj_property,
22
22
  outlineSVGData = _ref.outlineSVGData,
23
- cds = _ref.cds;
23
+ cds = _ref.cds,
24
+ _ref$width_unit = _ref.width_unit,
25
+ width_unit = _ref$width_unit === void 0 ? 'in' : _ref$width_unit,
26
+ _ref$height_unit = _ref.height_unit,
27
+ height_unit = _ref$height_unit === void 0 ? 'in' : _ref$height_unit,
28
+ _ref$length_unit = _ref.length_unit,
29
+ length_unit = _ref$length_unit === void 0 ? 'in' : _ref$length_unit;
30
+ var widthUnit = width_unit === 'inch' ? 'in' : width_unit;
31
+ var heightUnit = height_unit === 'inch' ? 'in' : height_unit;
32
+ var lengthUnit = length_unit === 'inch' ? 'in' : length_unit;
24
33
  var _length = alti || 0;
25
- var length = convert(_length).from('in').to('cm');
34
+ var length = convert(_length).from(lengthUnit).to('cm');
26
35
  // const length = _length;
27
36
 
28
37
  var additional_props = [];
@@ -33,8 +42,8 @@ export default function (_ref) {
33
42
  type: 'length-measure',
34
43
  defaultValue: {
35
44
  _length: sizeinfo.width,
36
- _unit: 'in',
37
- length: convert(sizeinfo.width).from('in').to('cm')
45
+ _unit: widthUnit,
46
+ length: convert(sizeinfo.width).from(widthUnit).to('cm')
38
47
  }
39
48
  }
40
49
  };
@@ -46,8 +55,8 @@ export default function (_ref) {
46
55
  type: 'length-measure',
47
56
  defaultValue: {
48
57
  _length: sizeinfo.width,
49
- _unit: 'in',
50
- length: convert(sizeinfo.width).from('in').to('cm')
58
+ _unit: widthUnit,
59
+ length: convert(sizeinfo.width).from(widthUnit).to('cm')
51
60
  }
52
61
  },
53
62
  depth: {
@@ -55,8 +64,8 @@ export default function (_ref) {
55
64
  type: 'length-measure',
56
65
  defaultValue: {
57
66
  _length: sizeinfo.depth,
58
- _unit: 'in',
59
- length: convert(sizeinfo.depth).from('in').to('cm')
67
+ _unit: lengthUnit,
68
+ length: convert(sizeinfo.depth).from(lengthUnit).to('cm')
60
69
  }
61
70
  },
62
71
  height: {
@@ -64,8 +73,8 @@ export default function (_ref) {
64
73
  type: 'length-measure',
65
74
  defaultValue: {
66
75
  _length: sizeinfo.height,
67
- _unit: 'in',
68
- length: convert(sizeinfo.height).from('in').to('cm')
76
+ _unit: heightUnit,
77
+ length: convert(sizeinfo.height).from(heightUnit).to('cm')
69
78
  }
70
79
  }
71
80
  };
@@ -97,7 +106,7 @@ export default function (_ref) {
97
106
  type: 'length-measure',
98
107
  defaultValue: {
99
108
  _length: _length,
100
- _unit: 'in',
109
+ _unit: lengthUnit,
101
110
  length: length
102
111
  }
103
112
  },
@@ -138,6 +147,9 @@ export default function (_ref) {
138
147
  obj: obj_property,
139
148
  cds: cds,
140
149
  structure_json: structure_json,
150
+ width_unit: widthUnit,
151
+ length_unit: lengthUnit,
152
+ height_unit: heightUnit,
141
153
  render2D: function render2D(element, layer, scene) {
142
154
  return render2DItem.call(this, element, layer, scene, sizeinfo, layoutpos, is_corner, shape_svg);
143
155
  },
@@ -1001,18 +1001,13 @@ export function render3DItem(element, layer, scene, sizeinfo, structure_json, is
1001
1001
  if (!isEmpty(doorStyles)) {
1002
1002
  var _layer$toJS;
1003
1003
  var normalMap = doorStyles.get('base') || INITIAL_NORMAL_MAP;
1004
- if (isEmpty(counterTop.uri)) {
1005
- try {
1006
- counterTop = counterTop.toJS();
1007
- } catch (error) {
1008
- //@todo THIS IS A TEMPORARY FIX FOR COUNTERTOP TEXTURE UNDEFINED ISSUE
1009
- counterTop.uri = 'https://media.test.diydesignspace.com/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
1010
- console.log(error);
1011
- }
1012
- }
1013
1004
  if (isEmpty(counterTop.uri) && !isEmpty(layer === null || layer === void 0 || (_layer$toJS = layer.toJS()) === null || _layer$toJS === void 0 ? void 0 : _layer$toJS.counterTop.uri)) {
1014
1005
  counterTop.uri = layer.toJS().counterTop.uri;
1015
1006
  }
1007
+ if (isEmpty(counterTop.uri)) {
1008
+ //@todo THIS IS A TEMPORARY FIX FOR COUNTERTOP TEXTURE UNDEFINED ISSUE
1009
+ counterTop.uri = 'https://media.test.diydesignspace.com/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
1010
+ }
1016
1011
  var countTopMap = counterTop.uri;
1017
1012
  var interiorMap = doorStyles.get('interior');
1018
1013
  var countT = loadTexture(countTopMap);
package/es/class/item.js CHANGED
@@ -492,6 +492,9 @@ var Item = /*#__PURE__*/function () {
492
492
  }, {
493
493
  key: "storeDistArray",
494
494
  value: function storeDistArray(state, layerID, itemID, distArray) {
495
+ if (isEmpty(distArray)) return {
496
+ updatedState: state
497
+ };
495
498
  var curDistArray = state.getIn(['scene', 'layers', layerID, 'items', itemID, 'distArray']);
496
499
  distArray.forEach(function (dist) {
497
500
  dist[0] < 0 ? dist[0] = 0 : dist[0];
package/es/class/layer.js CHANGED
@@ -567,7 +567,7 @@ var Layer = /*#__PURE__*/function () {
567
567
  return v.id !== vertexID && GeometryUtils.samePoints(vertex, v) // &&
568
568
  //!v.lines.contains( vertexID ) &&
569
569
  //!v.areas.contains( vertexID )
570
- ;
570
+ ;
571
571
  });
572
572
  if (doubleVertices.isEmpty()) return {
573
573
  updatedState: state
@@ -103,6 +103,8 @@ var Project = /*#__PURE__*/function () {
103
103
  // sceneJSON && (sceneJSON.layers[layerID] = newlayer);
104
104
  // }
105
105
 
106
+ // check type of ceilHeight and make it to Number
107
+ if (typeof sceneJSON.layers[layerID].ceilHeight !== 'number') sceneJSON.layers[layerID].ceilHeight = Number(sceneJSON.layers[layerID].ceilHeight);
106
108
  var newScene = new Scene(sceneJSON);
107
109
  state = new State({
108
110
  scene: newScene.toJS(),
@@ -168,6 +170,8 @@ var Project = /*#__PURE__*/function () {
168
170
  // Matching state.doorStyle with layer.doorStyle
169
171
  if (state.getIn(['scene', 'layers', layerID, 'doorStyle'])) {
170
172
  doorStyle = state.getIn(['scene', 'layers', layerID, 'doorStyle']);
173
+ } else if (!isEmpty(doorStyle)) {
174
+ state = state.setIn(['scene', 'layers', layerID, 'doorStyle'], doorStyle);
171
175
  }
172
176
  state = state.merge({
173
177
  doorStyle: doorStyle,
@@ -828,11 +832,10 @@ var Project = /*#__PURE__*/function () {
828
832
  }
829
833
  }, {
830
834
  key: "createRoomWithShape",
831
- value: function createRoomWithShape(state, roomShapeType, width, height, doorStyle) {
835
+ value: function createRoomWithShape(state, roomShapeType, width, height, measurementUnit, doorStyle) {
832
836
  var catalog = state.catalog;
833
- // keep measurement unit, sceneHistory
837
+ // keep sceneHistory
834
838
  var curLayerID = state.scene.selectedLayer;
835
- var layerUnit = state.getIn(['scene', 'layers', curLayerID, 'unit']);
836
839
  var ceilHeight = state.getIn(['scene', 'layers', curLayerID, 'ceilHeight']);
837
840
  var sceneHistory = state.getIn(['sceneHistory']);
838
841
  state = this.newProject(state).updatedState;
@@ -847,8 +850,8 @@ var Project = /*#__PURE__*/function () {
847
850
  if (isEmpty(viewer)) return {
848
851
  updatedState: state
849
852
  };
850
- width = convert(width).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
851
- height = convert(height).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
853
+ width = convert(width).from(measurementUnit).to('cm');
854
+ height = convert(height).from(measurementUnit).to('cm');
852
855
  var halfWidth = width / 2;
853
856
  var halfHeight = height / 2;
854
857
  var viewerWidth = viewer.SVGWidth;
@@ -921,8 +924,7 @@ var Project = /*#__PURE__*/function () {
921
924
  }
922
925
  }
923
926
 
924
- // copy keeped measurement unit, sceneHistory
925
- state = state.setIn(['scene', 'layers', layerID, 'unit'], layerUnit);
927
+ // copy keeped sceneHistory
926
928
  state = state.setIn(['scene', 'layers', layerID, 'ceilHeight'], ceilHeight);
927
929
  state = state.setIn(['sceneHistory'], sceneHistory);
928
930
  state = centering2D(state);
@@ -34,28 +34,28 @@ export var STYLE_ROOM_SHAPE = {
34
34
  var STYLE_DASH = {
35
35
  stroke: DASH_LINE_COLOR,
36
36
  strokeDasharray: '4 4',
37
- strokeWidth: '2px',
37
+ strokeWidth: '1px',
38
38
  strokeLinecap: 'round'
39
39
  };
40
40
  var STYLE_ROOM_ELEMENT = {
41
41
  fill: ROOM_ELEMENT_MEASUREMENT_LINE_COLOR,
42
42
  stroke: ROOM_ELEMENT_MEASUREMENT_LINE_COLOR,
43
- strokeWidth: '2px'
43
+ strokeWidth: '1.5px'
44
44
  };
45
45
  var STYLE_BASE_ITEM = {
46
46
  fill: BASE_ITEM_MEASUREMENT_LINE_COLOR,
47
47
  stroke: BASE_ITEM_MEASUREMENT_LINE_COLOR,
48
- strokeWidth: '2px'
48
+ strokeWidth: '1.5px'
49
49
  };
50
50
  var STYLE_WALL_ITEM = {
51
51
  fill: WALL_ITEM_MEASUREMENT_LINE_COLOR,
52
52
  stroke: WALL_ITEM_MEASUREMENT_LINE_COLOR,
53
- strokeWidth: '2px'
53
+ strokeWidth: '1.5px'
54
54
  };
55
55
  var STYLE_DISTANCE = {
56
56
  fill: DISTANCE_MEASUREMENT_LINE_COLOR,
57
57
  stroke: DISTANCE_MEASUREMENT_LINE_COLOR,
58
- strokeWidth: '2px'
58
+ strokeWidth: '1.5px'
59
59
  };
60
60
  var selectStyle = function selectStyle(element, style) {
61
61
  return element.iFlag ? style : STYLE_DISTANCE;
@@ -1,13 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { convert } from "../../utils/convert-units-lite";
4
3
  import IDBroker from "../../utils/id-broker";
5
- import { LINE_THICKNESS, TEXT_COLOR_NEUTRAL_7, UNIT_FOOT, UNIT_METER } from "../../constants";
4
+ import { TEXT_COLOR_NEUTRAL_7 } from "../../constants";
6
5
  import { STYLE_ROOM_SHAPE } from "./line";
7
- var STYLE = {
8
- stroke: TEXT_COLOR_NEUTRAL_7,
9
- strokeWidth: '1px'
10
- };
6
+ import { getRulerDisplayData } from "../../utils/ruler";
11
7
  var BACKGROUNDSTYLE = {
12
8
  fill: 'transparent',
13
9
  fillOpacity: 0.8
@@ -31,13 +27,20 @@ export default function Ruler(_ref) {
31
27
  rulerUnit = _ref.rulerUnit,
32
28
  transform = _ref.transform,
33
29
  style = _ref.style;
34
- var ruLength = convert(length).from(unit).to(rulerUnit);
35
- var fixedLength = layer.unit === UNIT_METER || layer.unit === UNIT_FOOT ? 2 : 0;
36
- var distanceText = (Math.round(convert(ruLength).from(rulerUnit).to(layer.unit) * 100) / 100).toFixed(fixedLength);
37
- var textLength = (distanceText.length + layer.unit.length) * 9;
30
+ var _getRulerDisplayData = getRulerDisplayData({
31
+ length: length,
32
+ unit: unit,
33
+ rulerUnit: rulerUnit,
34
+ layerUnit: layer.unit
35
+ }),
36
+ distanceText = _getRulerDisplayData.distanceText,
37
+ unitStr = _getRulerDisplayData.unitStr,
38
+ textLength = _getRulerDisplayData.textLength,
39
+ bShowText = _getRulerDisplayData.bShowText,
40
+ bShowLine = _getRulerDisplayData.bShowLine;
38
41
  return /*#__PURE__*/React.createElement("g", {
39
42
  transform: transform
40
- }, /*#__PURE__*/React.createElement("g", {
43
+ }, bShowText && /*#__PURE__*/React.createElement("g", {
41
44
  id: "ruler"
42
45
  }, /*#__PURE__*/React.createElement("rect", {
43
46
  id: "ruler_rect_".concat(IDBroker.acquireID()),
@@ -54,7 +57,7 @@ export default function Ruler(_ref) {
54
57
  transform: "scale(1, -1)",
55
58
  style: STYLE_TEXT,
56
59
  fill: TEXT_COLOR_NEUTRAL_7
57
- }, distanceText, layer.unit === 'in' ? '"' : layer.unit)), /*#__PURE__*/React.createElement("line", {
60
+ }, distanceText, unitStr)), bShowLine && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("line", {
58
61
  x1: style === STYLE_ROOM_SHAPE ? 0 : 4,
59
62
  y1: "0",
60
63
  x2: (length - textLength) / 2 < 0 ? 0 : (length - textLength) / 2,
@@ -72,7 +75,7 @@ export default function Ruler(_ref) {
72
75
  }), /*#__PURE__*/React.createElement("polygon", {
73
76
  points: "".concat(length - 3, ", 0, ").concat(length - 6.5, ", 2, ").concat(length - 6.5, ", -2"),
74
77
  style: style
75
- })));
78
+ }))));
76
79
  }
77
80
  Ruler.propTypes = {
78
81
  length: PropTypes.number.isRequired,
@@ -1,12 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { convert } from "../../utils/convert-units-lite";
4
- import { UNIT_FOOT, UNIT_METER } from "../../constants";
5
- var ARROW_STYLE = {
6
- stroke: '#1183B7',
7
- strokeWidth: '2px',
8
- strokeLinecap: 'round'
9
- };
3
+ import { getRulerDisplayData } from "../../utils/ruler";
10
4
  var STYLE = {
11
5
  stroke: '#455A64',
12
6
  fill: '#455A64',
@@ -32,10 +26,17 @@ export default function RulerDist(_ref) {
32
26
  transform = _ref.transform,
33
27
  angle = _ref.angle,
34
28
  rotation = _ref.rotation;
35
- var ruLength = convert(length).from(unit).to(rulerUnit);
36
- var fixedLength = layer.unit === UNIT_METER || layer.unit === UNIT_FOOT ? 2 : 0;
37
- var distanceText = (Math.round(convert(ruLength).from(rulerUnit).to(layer.unit) * 100) / 100).toFixed(fixedLength);
38
- var textLength = (distanceText.length + layer.unit.length) * 8;
29
+ var _getRulerDisplayData = getRulerDisplayData({
30
+ length: length,
31
+ unit: unit,
32
+ rulerUnit: rulerUnit,
33
+ layerUnit: layer.unit
34
+ }),
35
+ distanceText = _getRulerDisplayData.distanceText,
36
+ unitStr = _getRulerDisplayData.unitStr,
37
+ textLength = _getRulerDisplayData.textLength,
38
+ bShowText = _getRulerDisplayData.bShowText,
39
+ bShowLine = _getRulerDisplayData.bShowLine;
39
40
  var textangle = angle + 90;
40
41
  var textRotation = 1;
41
42
  var ay = 2;
@@ -67,47 +68,32 @@ export default function RulerDist(_ref) {
67
68
  textRotation = 180;
68
69
  ay = 5;
69
70
  }
70
- if (ruLength > 0) {
71
- if (ruLength < 28) {
72
- return /*#__PURE__*/React.createElement("g", {
73
- transform: transform
74
- }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("text", {
75
- x: "0",
76
- y: "0",
77
- transform: "translate(".concat(length / 2, ",").concat(ay, ") scale(1, -1) rotate(").concat(textRotation, ")"),
78
- style: STYLE_TEXT
79
- }, distanceText, layer.unit === 'in' ? '"' : layer.unit)));
80
- } else {
81
- return /*#__PURE__*/React.createElement("g", {
82
- transform: transform
83
- }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("text", {
84
- x: "0",
85
- y: "0",
86
- transform: "translate(".concat(length / 2, ",").concat(ay, ") scale(1, -1) rotate(").concat(textRotation, ")"),
87
- style: STYLE_TEXT
88
- }, distanceText, layer.unit === 'in' ? '"' : layer.unit)), /*#__PURE__*/React.createElement("line", {
89
- x1: "2",
90
- y1: "0",
91
- x2: (length - textLength) / 2 < 0 ? 0 : (length - textLength) / 2,
92
- y2: "0",
93
- style: STYLE
94
- }), /*#__PURE__*/React.createElement("polygon", {
95
- points: "1, 0, 4.5, -2, 4.5, 2 ",
96
- style: STYLE
97
- }), /*#__PURE__*/React.createElement("line", {
98
- x1: (length + textLength) / 2 < 0 ? 0 : (length + textLength) / 2 < length ? (length + textLength) / 2 : length,
99
- y1: "0",
100
- x2: length,
101
- y2: "0",
102
- style: STYLE
103
- }), /*#__PURE__*/React.createElement("polygon", {
104
- points: "".concat(length - 1, ", 0, ").concat(length - 4.5, ", 2, ").concat(length - 4.5, ", -2"),
105
- style: STYLE
106
- }));
107
- }
108
- } else {
109
- return null;
110
- }
71
+ return /*#__PURE__*/React.createElement("g", {
72
+ transform: transform
73
+ }, bShowText && /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("text", {
74
+ x: "0",
75
+ y: "0",
76
+ transform: "translate(".concat(length / 2, ",").concat(ay, ") scale(1, -1) rotate(").concat(textRotation, ")"),
77
+ style: STYLE_TEXT
78
+ }, distanceText, unitStr)), bShowLine && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("line", {
79
+ x1: "2",
80
+ y1: "0",
81
+ x2: (length - textLength) / 2 < 0 ? 0 : (length - textLength) / 2,
82
+ y2: "0",
83
+ style: STYLE
84
+ }), /*#__PURE__*/React.createElement("polygon", {
85
+ points: "1, 0, 4.5, -2, 4.5, 2 ",
86
+ style: STYLE
87
+ }), /*#__PURE__*/React.createElement("line", {
88
+ x1: (length + textLength) / 2 < 0 ? 0 : (length + textLength) / 2 < length ? (length + textLength) / 2 : length,
89
+ y1: "0",
90
+ x2: length,
91
+ y2: "0",
92
+ style: STYLE
93
+ }), /*#__PURE__*/React.createElement("polygon", {
94
+ points: "".concat(length - 1, ", 0, ").concat(length - 4.5, ", 2, ").concat(length - 4.5, ", -2"),
95
+ style: STYLE
96
+ })));
111
97
  }
112
98
  RulerDist.propTypes = {
113
99
  length: PropTypes.number.isRequired,
@@ -835,11 +835,15 @@ export default function Viewer2D(_ref, _ref2) {
835
835
  var event = viewerEvent.originalEvent;
836
836
  var parent = document.querySelector('#kitchen-simulator-container');
837
837
  var targetRect = event.target.getBoundingClientRect();
838
- var parentRect = parent.getBoundingClientRect();
839
- var left = targetRect.left - parentRect.left;
840
- var top = targetRect.top - parentRect.top;
841
- left = left - (200 - targetRect.width) / 2;
842
- top = top - (50 - targetRect.height) / 2;
838
+ var left = targetRect.left;
839
+ var top = targetRect.top;
840
+ if (!isEmpty(parent)) {
841
+ var parentRect = parent.getBoundingClientRect();
842
+ left = targetRect.left - parentRect.left;
843
+ top = targetRect.top - parentRect.top;
844
+ left = left - (200 - targetRect.width) / 2;
845
+ top = top - (50 - targetRect.height) / 2;
846
+ }
843
847
  if (!mode.includes('ING')) {
844
848
  setToolbar('');
845
849
  }
@@ -931,6 +935,7 @@ export default function Viewer2D(_ref, _ref2) {
931
935
  // handle action when click elevation about selected line
932
936
  var _mode = MODE_ELEVATION_VIEW;
933
937
  projectActions.setMode(_mode);
938
+ internalType = constants.INTERNAL_EVENT_TOGGLE_TO_ELEVATION;
934
939
  break;
935
940
  } else {
936
941
  var tlines = [];