mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Make InstancesEditor initialization more robust against new react-dnd versions
This commit is contained in:
@@ -34,7 +34,7 @@ const styles = {
|
||||
|
||||
type ScrollableComponent = {
|
||||
scrollTo: (number, number) => void,
|
||||
getViewPosition: () => ViewPosition,
|
||||
getViewPosition: () => ?ViewPosition,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -121,7 +121,9 @@ export const addScrollbars = (WrappedComponent: any) => {
|
||||
};
|
||||
|
||||
_handleViewPositionChange = throttle(
|
||||
(viewPosition: ViewPosition) => {
|
||||
(viewPosition: ?ViewPosition) => {
|
||||
if (!viewPosition) return;
|
||||
|
||||
this._setAndAdjust({
|
||||
xValue: viewPosition.getViewX(),
|
||||
yValue: viewPosition.getViewY(),
|
||||
|
@@ -37,6 +37,22 @@ export default class InstancesEditorContainer extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Initialize the PIXI renderer, if possible
|
||||
if (this.canvasArea && !this.pixiRenderer) {
|
||||
this._initializeCanvasAndRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
// Initialize the PIXI renderer, if not already done.
|
||||
// This can happen if canvasArea was not rendered
|
||||
// just after the mount (depends on react-dnd versions?).
|
||||
if (this.canvasArea && !this.pixiRenderer) {
|
||||
this._initializeCanvasAndRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
_initializeCanvasAndRenderer() {
|
||||
this.pixiRenderer = PIXI.autoDetectRenderer(
|
||||
this.props.width,
|
||||
this.props.height
|
||||
@@ -544,7 +560,7 @@ export default class InstancesEditorContainer extends Component {
|
||||
);
|
||||
};
|
||||
|
||||
getViewPosition = () => {
|
||||
getViewPosition = () /*: ?ViewPosition */ => {
|
||||
return this.viewPosition;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user