diff --git a/packages/scratch-gui/src/components/monitor-list/monitor-list.jsx b/packages/scratch-gui/src/components/monitor-list/monitor-list.jsx
index e4da715b0b..f72f4389e9 100644
--- a/packages/scratch-gui/src/components/monitor-list/monitor-list.jsx
+++ b/packages/scratch-gui/src/components/monitor-list/monitor-list.jsx
@@ -11,39 +11,36 @@ import styles from './monitor-list.css';
const MonitorList = props => (
-
- {props.monitors.valueSeq().filter(m => m.visible)
- .map(monitorData => (
-
- ))}
-
+ {props.monitors.valueSeq().filter(m => m.visible)
+ .map(monitorData => (
+
+ ))}
);
@@ -55,7 +52,8 @@ MonitorList.propTypes = {
width: PropTypes.number,
height: PropTypes.number,
widthDefault: PropTypes.number,
- heightDefault: PropTypes.number
+ heightDefault: PropTypes.number,
+ scale: PropTypes.number
}).isRequired
};
diff --git a/packages/scratch-gui/src/components/monitor/monitor.jsx b/packages/scratch-gui/src/components/monitor/monitor.jsx
index d9ceb92695..95d6c550bc 100644
--- a/packages/scratch-gui/src/components/monitor/monitor.jsx
+++ b/packages/scratch-gui/src/components/monitor/monitor.jsx
@@ -52,6 +52,9 @@ const MonitorComponent = props => (
defaultClassNameDragging={styles.dragging}
disabled={!props.draggable}
onStop={props.onDragEnd}
+ scale={props.scale} // Used for moving the monitor at the correct speed
+ grid={[1 * props.scale, 1 * props.scale]} // Tell the Draggable to round the coordinates
+ // See https://github.com/react-grid-layout/react-draggable/issues/664 on why it's not just [1, 1]
>
that Scratch uses doesn't round the coordinates when
+ // it passes them to the event handler, only when it sets the CSS transform.
+ // Newer versions of would round the coordinates, but with floating point errors
+ // so it would still need the manual rounding
+ x = Math.round(x);
+ y = Math.round(y);
+
const newX = parseInt(this.element.style.left, 10) + x;
const newY = parseInt(this.element.style.top, 10) + y;
this.props.onDragEnd(
@@ -208,6 +215,7 @@ class Monitor extends React.Component {
componentRef={this.setElement}
{...monitorProps}
draggable={this.props.draggable}
+ scale={this.props.scale}
height={this.props.height}
isDiscrete={this.props.isDiscrete}
max={this.props.max}
@@ -234,6 +242,7 @@ class Monitor extends React.Component {
Monitor.propTypes = {
addMonitorRect: PropTypes.func.isRequired,
draggable: PropTypes.bool,
+ scale: PropTypes.number,
height: PropTypes.number,
id: PropTypes.string.isRequired,
intl: intlShape,