Remove goog.events.BrowserFeature dependency.

This commit is contained in:
Neil Fraser
2019-06-05 17:01:32 -07:00
committed by Neil Fraser
parent a18aa76e67
commit e8d8798ecf
3 changed files with 16 additions and 6 deletions

View File

@@ -27,9 +27,9 @@
goog.provide('Blockly.Scrollbar');
goog.provide('Blockly.ScrollbarPair');
goog.require('Blockly.Touch');
goog.require('Blockly.utils');
goog.require('goog.events.BrowserFeature');
goog.require('goog.math.Coordinate');
@@ -303,7 +303,7 @@ Blockly.Scrollbar.prototype.containerVisible_ = true;
* Scrollbars should be larger on touch devices.
*/
Blockly.Scrollbar.scrollbarThickness = 15;
if (goog.events.BrowserFeature.TOUCH_ENABLED) {
if (Blockly.Touch.TOUCH_ENABLED) {
Blockly.Scrollbar.scrollbarThickness = 25;
}

View File

@@ -35,7 +35,6 @@ goog.require('Blockly.utils');
goog.require('Blockly.VerticalFlyout');
goog.require('goog.events');
goog.require('goog.events.BrowserFeature');
goog.require('goog.events.EventType');
goog.require('goog.html.SafeHtml');
goog.require('goog.math.Rect');
@@ -600,7 +599,7 @@ Blockly.Toolbox.TreeControl.prototype.enterDocument = function() {
Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);
// Add touch handler.
if (goog.events.BrowserFeature.TOUCH_ENABLED) {
if (Blockly.Touch.TOUCH_ENABLED) {
var el = this.getElement();
Blockly.bindEventWithChecks_(el, goog.events.EventType.TOUCHEND, this,
this.handleTouchEvent_);

View File

@@ -32,8 +32,19 @@ goog.provide('Blockly.Touch');
goog.require('Blockly.utils');
goog.require('goog.events.BrowserFeature');
/**
* Whether touch is enabled in the browser.
* Copied from Closure's goog.events.BrowserFeature.TOUCH_ENABLED
*/
Blockly.Touch.TOUCH_ENABLED =
('ontouchstart' in Blockly.utils.global ||
!!(Blockly.utils.global['document'] && document.documentElement &&
'ontouchstart' in document.documentElement) ||
// IE10 uses non-standard touch events, so it has a different check.
!!(Blockly.utils.global['navigator'] &&
(Blockly.utils.global['navigator']['maxTouchPoints'] ||
Blockly.utils.global['navigator']['msMaxTouchPoints'])))
/**
* Which touch events are we currently paying attention to?
@@ -60,7 +71,7 @@ if (Blockly.utils.global['PointerEvent']) {
'touchend': ['pointerup'],
'touchcancel': ['pointercancel']
};
} else if (goog.events.BrowserFeature.TOUCH_ENABLED) {
} else if (Blockly.Touch.TOUCH_ENABLED) {
Blockly.Touch.TOUCH_MAP = {
'mousedown': ['touchstart'],
'mousemove': ['touchmove'],