Remove last goog.dom dependency.

This commit is contained in:
Neil Fraser
2019-06-05 17:12:32 -07:00
committed by Neil Fraser
parent e8d8798ecf
commit 931cc85c83
2 changed files with 19 additions and 2 deletions

View File

@@ -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.

View File

@@ -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_();