From 931cc85c8380f2fb74ba9fc9e3a4f1ce3e3c477f Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 5 Jun 2019 17:12:32 -0700 Subject: [PATCH] Remove last goog.dom dependency. --- core/utils.js | 18 ++++++++++++++++++ core/workspace_svg.js | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/utils.js b/core/utils.js index 18ee689dd..a2d6da5fb 100644 --- a/core/utils.js +++ b/core/utils.js @@ -972,6 +972,24 @@ Blockly.utils.containsNode = function(parent, descendant) { Node.DOCUMENT_POSITION_CONTAINED_BY); }; +/** + * Gets the document scroll distance as a coordinate object. + * Copied from Closure's goog.dom.getDocumentScroll. + * @return {!goog.math.Coordinate} Object with values 'x' and 'y'. + */ +Blockly.utils.getDocumentScroll = function() { + var el = document.documentElement; + var win = window; + if (Blockly.userAgent.IE && win.pageYOffset != el.scrollTop) { + // The keyboard on IE10 touch devices shifts the page using the pageYOffset + // without modifying scrollTop. For this case, we want the body scroll + // offsets. + return new goog.math.Coordinate(el.scrollLeft, el.scrollTop); + } + return new goog.math.Coordinate( + win.pageXOffset || el.scrollLeft, win.pageYOffset || el.scrollTop); +}; + /** * Get a map of all the block's descendants mapping their type to the number of * children with that type. diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 37625df1a..a4b28dfb5 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -51,7 +51,6 @@ goog.require('Blockly.WorkspaceDragSurfaceSvg'); goog.require('Blockly.Xml'); goog.require('Blockly.ZoomControls'); -goog.require('goog.dom'); goog.require('goog.math.Coordinate'); @@ -774,7 +773,7 @@ Blockly.WorkspaceSvg.prototype.resize = function() { Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled = function() { /* eslint-disable indent */ - var currScroll = goog.dom.getDocumentScroll(); + var currScroll = Blockly.utils.getDocumentScroll(); if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_, currScroll)) { this.lastRecordedPageScroll_ = currScroll; this.updateScreenCalculations_();