redhotmagma-visualization 1.45.0 → 1.46.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/VisualizationContainer.js +34 -10
- package/package.json +2 -2
- package/src/VisualizationContainer.js +19 -0
|
@@ -112,12 +112,35 @@ var VisualizationContainer = exports.VisualizationContainer = /*#__PURE__*/funct
|
|
|
112
112
|
this.resizeSensor = new _cssElementQueries.ResizeSensor(container, this.onSizeChange);
|
|
113
113
|
}
|
|
114
114
|
}, {
|
|
115
|
-
key: "
|
|
116
|
-
value: function
|
|
117
|
-
|
|
115
|
+
key: "initMutationObserver",
|
|
116
|
+
value: function initMutationObserver() {
|
|
117
|
+
if (this.mutationObserver) {
|
|
118
|
+
this.mutationObserver.disconnect();
|
|
119
|
+
}
|
|
118
120
|
var _this$props2 = this.props,
|
|
119
121
|
visualization = _this$props2.visualization,
|
|
120
122
|
alignTargetElement = _this$props2.alignTargetElement;
|
|
123
|
+
if (!alignTargetElement) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.mutationObserver = new MutationObserver(function () {
|
|
127
|
+
(0, _updateFitSizeToElement.updateFitSizeToElement)(visualization, alignTargetElement).updateCameraPosition({
|
|
128
|
+
animate: true
|
|
129
|
+
});
|
|
130
|
+
visualization.render();
|
|
131
|
+
});
|
|
132
|
+
// do the update only when attributes have changed (e.g. style)
|
|
133
|
+
this.mutationObserver.observe(alignTargetElement, {
|
|
134
|
+
attributes: true
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "updateVisualization",
|
|
139
|
+
value: function updateVisualization() {
|
|
140
|
+
var prevProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
141
|
+
var _this$props3 = this.props,
|
|
142
|
+
visualization = _this$props3.visualization,
|
|
143
|
+
alignTargetElement = _this$props3.alignTargetElement;
|
|
121
144
|
var container = this.containerRef.current;
|
|
122
145
|
if (visualization !== prevProps.visualization) {
|
|
123
146
|
if (prevProps.visualization) {
|
|
@@ -139,13 +162,14 @@ var VisualizationContainer = exports.VisualizationContainer = /*#__PURE__*/funct
|
|
|
139
162
|
});
|
|
140
163
|
visualization.render();
|
|
141
164
|
}
|
|
165
|
+
this.initMutationObserver();
|
|
142
166
|
}
|
|
143
167
|
}, {
|
|
144
168
|
key: "componentWillUnmount",
|
|
145
169
|
value: function componentWillUnmount() {
|
|
146
|
-
var _this$
|
|
147
|
-
autoDispose = _this$
|
|
148
|
-
visualization = _this$
|
|
170
|
+
var _this$props4 = this.props,
|
|
171
|
+
autoDispose = _this$props4.autoDispose,
|
|
172
|
+
visualization = _this$props4.visualization;
|
|
149
173
|
autoDispose && visualization.dispose();
|
|
150
174
|
this.resizeSensor && this.resizeSensor.detach();
|
|
151
175
|
this.offObservers && this.offObservers();
|
|
@@ -177,10 +201,10 @@ var VisualizationContainer = exports.VisualizationContainer = /*#__PURE__*/funct
|
|
|
177
201
|
}, {
|
|
178
202
|
key: "render",
|
|
179
203
|
value: function render() {
|
|
180
|
-
var _this$
|
|
181
|
-
className = _this$
|
|
182
|
-
ProgressComponent = _this$
|
|
183
|
-
BrokenComponent = _this$
|
|
204
|
+
var _this$props5 = this.props,
|
|
205
|
+
className = _this$props5.className,
|
|
206
|
+
ProgressComponent = _this$props5.ProgressComponent,
|
|
207
|
+
BrokenComponent = _this$props5.BrokenComponent;
|
|
184
208
|
var broken = this.state.broken;
|
|
185
209
|
var style = _objectSpread(_objectSpread({}, className ? {} : defaultContainerStyle), broken && BrokenComponent && {
|
|
186
210
|
display: "none"
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redhotmagma-visualization",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/polyfill": "^7.12.1",
|
|
9
|
-
"@configuratorware/scripts": "1.
|
|
9
|
+
"@configuratorware/scripts": "1.46.0",
|
|
10
10
|
"@tweenjs/tween.js": "^17.6.0",
|
|
11
11
|
"console-polyfill": "^0.3.0",
|
|
12
12
|
"css-element-queries": "^1.2.3",
|
|
@@ -75,6 +75,24 @@ export class VisualizationContainer extends React.Component {
|
|
|
75
75
|
this.resizeSensor = new ResizeSensor(container, this.onSizeChange);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
initMutationObserver() {
|
|
79
|
+
if (this.mutationObserver) {
|
|
80
|
+
this.mutationObserver.disconnect();
|
|
81
|
+
}
|
|
82
|
+
const { visualization, alignTargetElement } = this.props;
|
|
83
|
+
if (!alignTargetElement) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.mutationObserver = new MutationObserver(() => {
|
|
87
|
+
updateFitSizeToElement(visualization, alignTargetElement).updateCameraPosition({
|
|
88
|
+
animate: true,
|
|
89
|
+
});
|
|
90
|
+
visualization.render();
|
|
91
|
+
});
|
|
92
|
+
// do the update only when attributes have changed (e.g. style)
|
|
93
|
+
this.mutationObserver.observe(alignTargetElement, { attributes: true });
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
updateVisualization(prevProps = {}) {
|
|
79
97
|
const { visualization, alignTargetElement } = this.props;
|
|
80
98
|
const container = this.containerRef.current;
|
|
@@ -105,6 +123,7 @@ export class VisualizationContainer extends React.Component {
|
|
|
105
123
|
});
|
|
106
124
|
visualization.render();
|
|
107
125
|
}
|
|
126
|
+
this.initMutationObserver();
|
|
108
127
|
}
|
|
109
128
|
|
|
110
129
|
componentWillUnmount() {
|