Skip to content

Commit 8109077

Browse files
author
Ives van Hoorne
committed
Fix preview interactivity and resetting alignment
1 parent ff043ab commit 8109077

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

packages/app/src/app/components/Preview/DevTools/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ export default class DevTools extends React.PureComponent<Props, State> {
235235
e.stopPropagation();
236236
this.handleClick();
237237
} else {
238-
// We do this to force a recalculation of the iframe height, this doesn't
239-
// happen when pointer events are disabled and in turn disables scroll.
240-
// It's hacky, but it's to fix a bug in the browser.
241238
setTimeout(() => {
242239
const height = this.state.height;
243240
if (height > 64) {

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/FlyingContainer.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,36 @@ class FlyingContainer extends React.Component<Props, State> {
6363
handleStartDrag = () => {
6464
this.setState({ dragging: true });
6565
this.setResizingStarted();
66-
67-
if (this.props.onPositionChange) {
68-
this.props.onPositionChange();
69-
}
7066
};
7167

7268
handleStopDrag = (e, data) => {
73-
const { x, y } = data;
69+
const { x, y, deltaX, deltaY } = data;
70+
const delta = deltaX + deltaY;
7471
this.setState({ dragging: false });
7572

73+
this.setResizingStopped(delta);
74+
7675
// We only set the bounds in the global store on stop, otherwise there are
7776
// other components constantly recalculating while dragging -> lag
7877
this.props.signals.editor.setPreviewBounds({ x, y });
79-
this.setResizingStopped();
8078
};
8179

8280
setResizingStarted = () => {
8381
this.props.signals.editor.resizingStarted();
84-
85-
if (this.props.onPositionChange) {
86-
this.props.onPositionChange();
87-
}
8882
};
8983

90-
setResizingStopped = () => {
84+
setResizingStopped = (delta = -1) => {
9185
this.props.signals.editor.resizingStopped();
9286

87+
if (delta !== 0) {
88+
if (this.props.onPositionChange) {
89+
this.props.onPositionChange();
90+
}
91+
this.fixPreviewInteractivity();
92+
}
93+
};
94+
95+
fixPreviewInteractivity = () => {
9396
// We do this to force a recalculation of the iframe height, this doesn't
9497
// happen when pointer events are disabled and in turn disables scroll.
9598
// It's hacky, but it's to fix a bug in the browser.

packages/app/src/app/pages/Sandbox/Editor/Content/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,13 @@ class EditorPreview extends React.Component<Props, State> {
444444
this.devtools = component;
445445
}
446446
}}
447-
setDragging={() => this.props.signals.editor.resizingStarted()}
447+
setDragging={dragging => {
448+
if (dragging) {
449+
this.props.signals.editor.resizingStarted();
450+
} else {
451+
this.props.signals.editor.resizingStopped();
452+
}
453+
}}
448454
sandboxId={sandbox.id}
449455
shouldExpandDevTools={store.preferences.showDevtools}
450456
zenMode={preferences.settings.zenMode}

0 commit comments

Comments
 (0)