Named exports from ol/has
This commit is contained in:
@@ -7,7 +7,7 @@ import BaseObject from './Object.js';
|
||||
import {listen} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {circular as circularPolygon} from './geom/Polygon.js';
|
||||
import _ol_has_ from './has.js';
|
||||
import {GEOLOCATION} from './has.js';
|
||||
import {toRadians} from './math.js';
|
||||
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
|
||||
|
||||
@@ -127,7 +127,7 @@ Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||
if (_ol_has_.GEOLOCATION) {
|
||||
if (GEOLOCATION) {
|
||||
const tracking = this.getTracking();
|
||||
if (tracking && this.watchId_ === undefined) {
|
||||
this.watchId_ = navigator.geolocation.watchPosition(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/MapBrowserEventHandler
|
||||
*/
|
||||
import {inherits} from './index.js';
|
||||
import _ol_has_ from './has.js';
|
||||
import {DEVICE_PIXEL_RATIO} from './has.js';
|
||||
import MapBrowserEventType from './MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from './MapBrowserPointerEvent.js';
|
||||
import {listen, unlistenByKey} from './events.js';
|
||||
@@ -50,7 +50,7 @@ const MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
* @private
|
||||
*/
|
||||
this.moveTolerance_ = moveTolerance ?
|
||||
moveTolerance * _ol_has_.DEVICE_PIXEL_RATIO : _ol_has_.DEVICE_PIXEL_RATIO;
|
||||
moveTolerance * DEVICE_PIXEL_RATIO : DEVICE_PIXEL_RATIO;
|
||||
|
||||
/**
|
||||
* The most recent "down" type event (or null if none have occurred).
|
||||
|
||||
@@ -22,7 +22,7 @@ import Event from './events/Event.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
|
||||
import {TRUE} from './functions.js';
|
||||
import _ol_has_ from './has.js';
|
||||
import {DEVICE_PIXEL_RATIO, TOUCH} from './has.js';
|
||||
import LayerGroup from './layer/Group.js';
|
||||
import {getMapRendererPlugins} from './plugins.js';
|
||||
import RendererType from './renderer/Type.js';
|
||||
@@ -136,7 +136,7 @@ const PluggableMap = function(options) {
|
||||
* @type {number}
|
||||
*/
|
||||
this.pixelRatio_ = options.pixelRatio !== undefined ?
|
||||
options.pixelRatio : _ol_has_.DEVICE_PIXEL_RATIO;
|
||||
options.pixelRatio : DEVICE_PIXEL_RATIO;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -206,7 +206,7 @@ const PluggableMap = function(options) {
|
||||
* @type {Element}
|
||||
*/
|
||||
this.viewport_ = document.createElement('DIV');
|
||||
this.viewport_.className = 'ol-viewport' + (_ol_has_.TOUCH ? ' ol-touch' : '');
|
||||
this.viewport_.className = 'ol-viewport' + (TOUCH ? ' ol-touch' : '');
|
||||
this.viewport_.style.position = 'relative';
|
||||
this.viewport_.style.overflow = 'hidden';
|
||||
this.viewport_.style.width = '100%';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {TRUE, FALSE} from '../functions.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import {WEBKIT, MAC} from '../has.js';
|
||||
const _ol_events_condition_ = {};
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ _ol_events_condition_.click = function(mapBrowserEvent) {
|
||||
_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) {
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return originalEvent.button == 0 &&
|
||||
!(_ol_has_.WEBKIT && _ol_has_.MAC && originalEvent.ctrlKey);
|
||||
!(WEBKIT && MAC && originalEvent.ctrlKey);
|
||||
};
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ _ol_events_condition_.noModifierKeys = function(mapBrowserEvent) {
|
||||
_ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return !originalEvent.altKey &&
|
||||
(_ol_has_.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
||||
(MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
||||
!originalEvent.shiftKey;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
*/
|
||||
import {HAS_WEBGL} from './index.js';
|
||||
|
||||
const _ol_has_ = {};
|
||||
|
||||
const ua = typeof navigator !== 'undefined' ?
|
||||
navigator.userAgent.toLowerCase() : '';
|
||||
|
||||
@@ -12,25 +10,25 @@ const ua = typeof navigator !== 'undefined' ?
|
||||
* User agent string says we are dealing with Firefox as browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.FIREFOX = ua.indexOf('firefox') !== -1;
|
||||
export const FIREFOX = ua.indexOf('firefox') !== -1;
|
||||
|
||||
/**
|
||||
* User agent string says we are dealing with Safari as browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') == -1;
|
||||
export const SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') == -1;
|
||||
|
||||
/**
|
||||
* User agent string says we are dealing with a WebKit engine.
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.WEBKIT = ua.indexOf('webkit') !== -1 && ua.indexOf('edge') == -1;
|
||||
export const WEBKIT = ua.indexOf('webkit') !== -1 && ua.indexOf('edge') == -1;
|
||||
|
||||
/**
|
||||
* User agent string says we are dealing with a Mac as platform.
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.MAC = ua.indexOf('macintosh') !== -1;
|
||||
export const MAC = ua.indexOf('macintosh') !== -1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,44 +38,22 @@ _ol_has_.MAC = ua.indexOf('macintosh') !== -1;
|
||||
* @type {number}
|
||||
* @api
|
||||
*/
|
||||
_ol_has_.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
||||
export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
||||
|
||||
|
||||
/**
|
||||
* True if the browser's Canvas implementation implements {get,set}LineDash.
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.CANVAS_LINE_DASH = false;
|
||||
|
||||
|
||||
/**
|
||||
* True if the and browsers support Canvas.
|
||||
* @const
|
||||
* @type {boolean}
|
||||
* @api
|
||||
*/
|
||||
_ol_has_.CANVAS = (
|
||||
/**
|
||||
* @return {boolean} Canvas supported.
|
||||
*/
|
||||
function() {
|
||||
if (!('HTMLCanvasElement' in window)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const context = document.createElement('CANVAS').getContext('2d');
|
||||
if (!context) {
|
||||
return false;
|
||||
} else {
|
||||
if (context.setLineDash !== undefined) {
|
||||
_ol_has_.CANVAS_LINE_DASH = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
export const CANVAS_LINE_DASH = function() {
|
||||
let has = false;
|
||||
try {
|
||||
has = !!document.createElement('CANVAS').getContext('2d').setLineDash;
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
return has;
|
||||
}();
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,7 +62,7 @@ _ol_has_.CANVAS = (
|
||||
* @type {boolean}
|
||||
* @api
|
||||
*/
|
||||
_ol_has_.GEOLOCATION = 'geolocation' in navigator;
|
||||
export const GEOLOCATION = 'geolocation' in navigator;
|
||||
|
||||
|
||||
/**
|
||||
@@ -95,7 +71,7 @@ _ol_has_.GEOLOCATION = 'geolocation' in navigator;
|
||||
* @type {boolean}
|
||||
* @api
|
||||
*/
|
||||
_ol_has_.TOUCH = 'ontouchstart' in window;
|
||||
export const TOUCH = 'ontouchstart' in window;
|
||||
|
||||
|
||||
/**
|
||||
@@ -103,7 +79,7 @@ _ol_has_.TOUCH = 'ontouchstart' in window;
|
||||
* @const
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.POINTER = 'PointerEvent' in window;
|
||||
export const POINTER = 'PointerEvent' in window;
|
||||
|
||||
|
||||
/**
|
||||
@@ -111,7 +87,7 @@ _ol_has_.POINTER = 'PointerEvent' in window;
|
||||
* @const
|
||||
* @type {boolean}
|
||||
*/
|
||||
_ol_has_.MSPOINTER = !!(navigator.msPointerEnabled);
|
||||
export const MSPOINTER = !!(navigator.msPointerEnabled);
|
||||
|
||||
|
||||
/**
|
||||
@@ -120,7 +96,4 @@ _ol_has_.MSPOINTER = !!(navigator.msPointerEnabled);
|
||||
* @type {boolean}
|
||||
* @api
|
||||
*/
|
||||
_ol_has_.WEBGL = HAS_WEBGL;
|
||||
|
||||
|
||||
export default _ol_has_;
|
||||
export const WEBGL = HAS_WEBGL;
|
||||
|
||||
@@ -6,7 +6,7 @@ import ViewHint from '../ViewHint.js';
|
||||
import condition from '../events/condition.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../has.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import {clamp} from '../math.js';
|
||||
|
||||
@@ -156,16 +156,16 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
||||
let delta;
|
||||
if (mapBrowserEvent.type == EventType.WHEEL) {
|
||||
delta = wheelEvent.deltaY;
|
||||
if (_ol_has_.FIREFOX &&
|
||||
if (FIREFOX &&
|
||||
wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
||||
delta /= _ol_has_.DEVICE_PIXEL_RATIO;
|
||||
delta /= DEVICE_PIXEL_RATIO;
|
||||
}
|
||||
if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
||||
delta *= 40;
|
||||
}
|
||||
} else if (mapBrowserEvent.type == EventType.MOUSEWHEEL) {
|
||||
delta = -wheelEvent.wheelDeltaY;
|
||||
if (_ol_has_.SAFARI) {
|
||||
if (SAFARI) {
|
||||
delta /= 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import EventTarget from '../events/EventTarget.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import {POINTER, MSPOINTER, TOUCH} from '../has.js';
|
||||
import PointerEventType from '../pointer/EventType.js';
|
||||
import MouseSource from '../pointer/MouseSource.js';
|
||||
import MsSource from '../pointer/MsSource.js';
|
||||
@@ -86,15 +86,15 @@ inherits(PointerEventHandler, EventTarget);
|
||||
* that generate pointer events.
|
||||
*/
|
||||
PointerEventHandler.prototype.registerSources = function() {
|
||||
if (_ol_has_.POINTER) {
|
||||
if (POINTER) {
|
||||
this.registerSource('native', new NativeSource(this));
|
||||
} else if (_ol_has_.MSPOINTER) {
|
||||
} else if (MSPOINTER) {
|
||||
this.registerSource('ms', new MsSource(this));
|
||||
} else {
|
||||
const mouseSource = new MouseSource(this);
|
||||
this.registerSource('mouse', mouseSource);
|
||||
|
||||
if (_ol_has_.TOUCH) {
|
||||
if (TOUCH) {
|
||||
this.registerSource('touch', new TouchSource(this, mouseSource));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/render
|
||||
*/
|
||||
import _ol_has_ from './has.js';
|
||||
import {DEVICE_PIXEL_RATIO} from './has.js';
|
||||
import _ol_transform_ from './transform.js';
|
||||
import CanvasImmediateRenderer from './render/canvas/Immediate.js';
|
||||
|
||||
@@ -29,7 +29,7 @@ import CanvasImmediateRenderer from './render/canvas/Immediate.js';
|
||||
export function toContext(context, opt_options) {
|
||||
const canvas = context.canvas;
|
||||
const options = opt_options ? opt_options : {};
|
||||
const pixelRatio = options.pixelRatio || _ol_has_.DEVICE_PIXEL_RATIO;
|
||||
const pixelRatio = options.pixelRatio || DEVICE_PIXEL_RATIO;
|
||||
const size = options.size;
|
||||
if (size) {
|
||||
canvas.width = size[0] * pixelRatio;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {intersects} from '../../extent.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import VectorContext from '../VectorContext.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
@@ -728,7 +728,7 @@ CanvasImmediateRenderer.prototype.setContextStrokeState_ = function(strokeState)
|
||||
const contextStrokeState = this.contextStrokeState_;
|
||||
if (!contextStrokeState) {
|
||||
context.lineCap = strokeState.lineCap;
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
if (CANVAS_LINE_DASH) {
|
||||
context.setLineDash(strokeState.lineDash);
|
||||
context.lineDashOffset = strokeState.lineDashOffset;
|
||||
}
|
||||
@@ -749,7 +749,7 @@ CanvasImmediateRenderer.prototype.setContextStrokeState_ = function(strokeState)
|
||||
if (contextStrokeState.lineCap != strokeState.lineCap) {
|
||||
contextStrokeState.lineCap = context.lineCap = strokeState.lineCap;
|
||||
}
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
if (CANVAS_LINE_DASH) {
|
||||
if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {
|
||||
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import _ol_geom_flat_inflate_ from '../../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_length_ from '../../geom/flat/length.js';
|
||||
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import VectorContext from '../VectorContext.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
@@ -479,7 +479,7 @@ CanvasReplay.prototype.setStrokeStyle_ = function(context, instruction) {
|
||||
context.lineCap = /** @type {string} */ (instruction[3]);
|
||||
context.lineJoin = /** @type {string} */ (instruction[4]);
|
||||
context.miterLimit = /** @type {number} */ (instruction[5]);
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
if (CANVAS_LINE_DASH) {
|
||||
context.lineDashOffset = /** @type {number} */ (instruction[7]);
|
||||
context.setLineDash(/** @type {Array.<number>} */ (instruction[6]));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {createCanvasContext2D} from '../../dom.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import {CANVAS_LINE_DASH, SAFARI} from '../../has.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
import CanvasInstruction from '../canvas/Instruction.js';
|
||||
import CanvasReplay from '../canvas/Replay.js';
|
||||
@@ -314,11 +314,11 @@ CanvasTextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey
|
||||
context.font = textState.font;
|
||||
if (strokeKey) {
|
||||
context.strokeStyle = strokeState.strokeStyle;
|
||||
context.lineWidth = strokeWidth * (_ol_has_.SAFARI ? scale : 1);
|
||||
context.lineWidth = strokeWidth * (SAFARI ? scale : 1);
|
||||
context.lineCap = strokeState.lineCap;
|
||||
context.lineJoin = strokeState.lineJoin;
|
||||
context.miterLimit = strokeState.miterLimit;
|
||||
if (_ol_has_.CANVAS_LINE_DASH && strokeState.lineDash.length) {
|
||||
if (CANVAS_LINE_DASH && strokeState.lineDash.length) {
|
||||
context.setLineDash(strokeState.lineDash);
|
||||
context.lineDashOffset = strokeState.lineDashOffset;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import WebGLTextureReplay from '../webgl/TextureReplay.js';
|
||||
@@ -269,7 +269,7 @@ WebGLTextReplay.prototype.addCharToAtlas_ = function(char) {
|
||||
ctx.miterLimit = /** @type {number} */ (state.miterLimit);
|
||||
ctx.textAlign = 'left';
|
||||
ctx.textBaseline = 'top';
|
||||
if (_ol_has_.CANVAS_LINE_DASH && state.lineDash) {
|
||||
if (CANVAS_LINE_DASH && state.lineDash) {
|
||||
//FIXME: use pixelRatio
|
||||
ctx.setLineDash(state.lineDash);
|
||||
ctx.lineDashOffset = /** @type {number} */ (state.lineDashOffset);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {stableSort} from '../../array.js';
|
||||
import {CLASS_UNSELECTABLE} from '../../css.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import {listen} from '../../events.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import {WEBGL} from '../../has.js';
|
||||
import Layer from '../../layer/Layer.js';
|
||||
import RenderEvent from '../../render/Event.js';
|
||||
import RenderEventType from '../../render/EventType.js';
|
||||
@@ -175,7 +175,7 @@ inherits(WebGLMapRenderer, MapRenderer);
|
||||
* @return {boolean} The renderer can render the layer.
|
||||
*/
|
||||
WebGLMapRenderer['handles'] = function(type) {
|
||||
return _ol_has_.WEBGL && type === RendererType.WEBGL;
|
||||
return WEBGL && type === RendererType.WEBGL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import {asColorLike} from '../colorlike.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import {CANVAS_LINE_DASH} from '../has.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_render_canvas_ from '../render/canvas.js';
|
||||
import ImageStyle from '../style/Image.js';
|
||||
@@ -334,7 +334,7 @@ RegularShape.prototype.render_ = function(atlasManager) {
|
||||
}
|
||||
lineDash = this.stroke_.getLineDash();
|
||||
lineDashOffset = this.stroke_.getLineDashOffset();
|
||||
if (!_ol_has_.CANVAS_LINE_DASH) {
|
||||
if (!CANVAS_LINE_DASH) {
|
||||
lineDash = null;
|
||||
lineDashOffset = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user