mirror of
https://github.com/google/blockly.git
synced 2026-03-10 07:10:11 +01:00
Remove calls to goog.dom.getViewportSize
document.documentElement.clientWidth/clientHeight seems to work everywhere Blockly works. Closure’s functions are mind-numbingly complex due to IE5, old WebKit, Opera 8, and others.
This commit is contained in:
@@ -30,9 +30,9 @@ goog.provide('Blockly.DropDownDiv');
|
||||
|
||||
goog.require('Blockly.utils');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.style');
|
||||
|
||||
|
||||
/**
|
||||
* Class for drop-down div.
|
||||
* @constructor
|
||||
|
||||
@@ -37,8 +37,6 @@ goog.provide('Blockly.Tooltip');
|
||||
|
||||
goog.require('Blockly.utils');
|
||||
|
||||
goog.require('goog.dom');
|
||||
|
||||
|
||||
/**
|
||||
* Is a tooltip currently showing?
|
||||
@@ -303,7 +301,8 @@ Blockly.Tooltip.show_ = function() {
|
||||
Blockly.Tooltip.DIV.appendChild(div);
|
||||
}
|
||||
var rtl = Blockly.Tooltip.element_.RTL;
|
||||
var windowSize = goog.dom.getViewportSize();
|
||||
var windowWidth = document.documentElement.clientWidth;
|
||||
var windowHeight = document.documentElement.clientHeight;
|
||||
// Display the tooltip.
|
||||
Blockly.Tooltip.DIV.style.direction = rtl ? 'rtl' : 'ltr';
|
||||
Blockly.Tooltip.DIV.style.display = 'block';
|
||||
@@ -318,7 +317,7 @@ Blockly.Tooltip.show_ = function() {
|
||||
var anchorY = Blockly.Tooltip.lastY_ + Blockly.Tooltip.OFFSET_Y;
|
||||
|
||||
if (anchorY + Blockly.Tooltip.DIV.offsetHeight >
|
||||
windowSize.height + window.scrollY) {
|
||||
windowHeight + window.scrollY) {
|
||||
// Falling off the bottom of the screen; shift the tooltip up.
|
||||
anchorY -= Blockly.Tooltip.DIV.offsetHeight + 2 * Blockly.Tooltip.OFFSET_Y;
|
||||
}
|
||||
@@ -327,10 +326,10 @@ Blockly.Tooltip.show_ = function() {
|
||||
anchorX = Math.max(Blockly.Tooltip.MARGINS - window.scrollX, anchorX);
|
||||
} else {
|
||||
if (anchorX + Blockly.Tooltip.DIV.offsetWidth >
|
||||
windowSize.width + window.scrollX - 2 * Blockly.Tooltip.MARGINS) {
|
||||
windowWidth + window.scrollX - 2 * Blockly.Tooltip.MARGINS) {
|
||||
// Falling off the right edge of the screen;
|
||||
// clamp the tooltip on the edge.
|
||||
anchorX = windowSize.width - Blockly.Tooltip.DIV.offsetWidth -
|
||||
anchorX = windowWidth - Blockly.Tooltip.DIV.offsetWidth -
|
||||
2 * Blockly.Tooltip.MARGINS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ goog.provide('Blockly.utils');
|
||||
|
||||
goog.require('Blockly.userAgent');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.math.Coordinate');
|
||||
|
||||
|
||||
@@ -909,13 +908,11 @@ Blockly.utils.setCssTransform = function(node, transform) {
|
||||
* @package
|
||||
*/
|
||||
Blockly.utils.getViewportBBox = function() {
|
||||
// Pixels.
|
||||
var windowSize = goog.dom.getViewportSize();
|
||||
// Pixels, in window coordinates.
|
||||
var scrollOffset = goog.style.getViewportPageOffset(document);
|
||||
return {
|
||||
right: windowSize.width + scrollOffset.x,
|
||||
bottom: windowSize.height + scrollOffset.y,
|
||||
right: document.documentElement.clientWidth + scrollOffset.x,
|
||||
bottom: document.documentElement.clientHeight + scrollOffset.y,
|
||||
top: scrollOffset.y,
|
||||
left: scrollOffset.x
|
||||
};
|
||||
|
||||
@@ -767,8 +767,7 @@ Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled =
|
||||
function() {
|
||||
/* eslint-disable indent */
|
||||
var currScroll = goog.dom.getDocumentScroll();
|
||||
if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_,
|
||||
currScroll)) {
|
||||
if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_, currScroll)) {
|
||||
this.lastRecordedPageScroll_ = currScroll;
|
||||
this.updateScreenCalculations_();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user