Migrate core/workspace_dragger.js named requires

This commit is contained in:
kozbial
2021-07-29 15:56:08 -07:00
committed by Monica Kozbial
parent 423fa02e8f
commit 75a98e6204

View File

@@ -13,9 +13,11 @@
goog.module('Blockly.WorkspaceDragger');
goog.module.declareLegacyNamespace();
goog.require('Blockly.utils.Coordinate');
goog.requireType('Blockly.WorkspaceSvg');
// TODO(#5073): Add Blockly require after fixing circular dependency.
// goog.require('Blockly');
const Coordinate = goog.require('Blockly.utils.Coordinate');
/* eslint-disable-next-line no-unused-vars */
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
/**
@@ -24,12 +26,12 @@ goog.requireType('Blockly.WorkspaceSvg');
* Note that the workspace itself manages whether or not it has a drag surface
* and how to do translations based on that. This simply passes the right
* commands based on events.
* @param {!Blockly.WorkspaceSvg} workspace The workspace to drag.
* @param {!WorkspaceSvg} workspace The workspace to drag.
* @constructor
*/
const WorkspaceDragger = function(workspace) {
/**
* @type {!Blockly.WorkspaceSvg}
* @type {!WorkspaceSvg}
* @private
*/
this.workspace_ = workspace;
@@ -51,10 +53,10 @@ const WorkspaceDragger = function(workspace) {
/**
* The scroll position of the workspace at the beginning of the drag.
* Coordinate system: pixel coordinates.
* @type {!Blockly.utils.Coordinate}
* @type {!Coordinate}
* @protected
*/
this.startScrollXY_ = new Blockly.utils.Coordinate(
this.startScrollXY_ = new Coordinate(
workspace.scrollX, workspace.scrollY);
};
@@ -80,7 +82,7 @@ WorkspaceDragger.prototype.startDrag = function() {
/**
* Finish dragging the workspace and put everything back where it belongs.
* @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has
* @param {!Coordinate} currentDragDeltaXY How far the pointer has
* moved from the position at the start of the drag, in pixel coordinates.
* @package
*/
@@ -92,12 +94,12 @@ WorkspaceDragger.prototype.endDrag = function(currentDragDeltaXY) {
/**
* Move the workspace based on the most recent mouse movements.
* @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has
* @param {!Coordinate} currentDragDeltaXY How far the pointer has
* moved from the position at the start of the drag, in pixel coordinates.
* @package
*/
WorkspaceDragger.prototype.drag = function(currentDragDeltaXY) {
const newXY = Blockly.utils.Coordinate.sum(this.startScrollXY_, currentDragDeltaXY);
const newXY = Coordinate.sum(this.startScrollXY_, currentDragDeltaXY);
if (this.horizontalScrollEnabled_ && this.verticalScrollEnabled_) {
this.workspace_.scroll(newXY.x, newXY.y);