Named exports from ol/has
This commit is contained in:
@@ -2,7 +2,7 @@ import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import * as _ol_extent_ from '../src/ol/extent.js';
|
||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
||||
import _ol_has_ from '../src/ol/has.js';
|
||||
import {DEVICE_PIXEL_RATIO} from '../src/ol/has.js';
|
||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
@@ -15,7 +15,7 @@ const context = canvas.getContext('2d');
|
||||
|
||||
// Gradient and pattern are in canvas pixel space, so we adjust for the
|
||||
// renderer's pixel ratio
|
||||
const pixelRatio = _ol_has_.DEVICE_PIXEL_RATIO;
|
||||
const pixelRatio = DEVICE_PIXEL_RATIO;
|
||||
|
||||
// Generate a rainbow gradient
|
||||
function gradient(feature, resolution) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
||||
import _ol_has_ from '../src/ol/has.js';
|
||||
import {WEBGL} from '../src/ol/has.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
|
||||
if (!_ol_has_.WEBGL) {
|
||||
if (!WEBGL) {
|
||||
const info = document.getElementById('no-webgl');
|
||||
/**
|
||||
* display error message
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import _ol_has_ from '../src/ol/has.js';
|
||||
import {WEBGL} from '../src/ol/has.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
|
||||
@@ -19,7 +19,7 @@ const map1 = new Map({
|
||||
view: view
|
||||
});
|
||||
|
||||
if (_ol_has_.WEBGL) {
|
||||
if (WEBGL) {
|
||||
const map2 = new Map({
|
||||
target: 'webglMap',
|
||||
renderer: /** @type {Array<ol.renderer.Type>} */ (['webgl', 'canvas']),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import WMTSCapabilities from '../src/ol/format/WMTSCapabilities.js';
|
||||
import _ol_has_ from '../src/ol/has.js';
|
||||
import {DEVICE_PIXEL_RATIO} from '../src/ol/has.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import WMTS from '../src/ol/source/WMTS.js';
|
||||
|
||||
@@ -11,7 +11,7 @@ const capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml'
|
||||
// HiDPI support:
|
||||
// * Use 'bmaphidpi' layer (pixel ratio 2) for device pixel ratio > 1
|
||||
// * Use 'geolandbasemap' layer (pixel ratio 1) for device pixel ratio == 1
|
||||
const hiDPI = _ol_has_.DEVICE_PIXEL_RATIO > 1;
|
||||
const hiDPI = DEVICE_PIXEL_RATIO > 1;
|
||||
const layer = hiDPI ? 'bmaphidpi' : 'geolandbasemap';
|
||||
const tilePixelRatio = hiDPI ? 2 : 1;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import Map from '../../../../src/ol/Map.js';
|
||||
import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import Event from '../../../../src/ol/events/Event.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../../../../src/ol/has.js';
|
||||
import Interaction from '../../../../src/ol/interaction/Interaction.js';
|
||||
import MouseWheelZoom from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
||||
|
||||
@@ -62,43 +62,41 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
|
||||
describe('handleEvent()', function() {
|
||||
|
||||
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
const origHasFirefox = _ol_has_.FIREFOX;
|
||||
_ol_has_.FIREFOX = true;
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||
_ol_has_.FIREFOX = origHasFirefox;
|
||||
done();
|
||||
if (FIREFOX) {
|
||||
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||
done();
|
||||
});
|
||||
const event = new MapBrowserEvent('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: DEVICE_PIXEL_RATIO,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
const event = new MapBrowserEvent('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: _ol_has_.DEVICE_PIXEL_RATIO,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
const origHasFirefox = _ol_has_.FIREFOX;
|
||||
_ol_has_.FIREFOX = false;
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||
_ol_has_.FIREFOX = origHasFirefox;
|
||||
done();
|
||||
if (!FIREFOX) {
|
||||
it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||
done();
|
||||
});
|
||||
const event = new MapBrowserEvent('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: 1,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
const event = new MapBrowserEvent('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: 1,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
describe('spying on ol.interaction.Interaction.zoomByDelta', function() {
|
||||
beforeEach(function() {
|
||||
@@ -126,45 +124,43 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works on Safari (wheel)', function(done) {
|
||||
const origHasSafari = _ol_has_.SAFARI;
|
||||
_ol_has_.SAFARI = true;
|
||||
map.once('postrender', function() {
|
||||
const call = Interaction.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
_ol_has_.SAFARI = origHasSafari;
|
||||
done();
|
||||
if (SAFARI) {
|
||||
it('works on Safari (wheel)', function(done) {
|
||||
map.once('postrender', function() {
|
||||
const call = Interaction.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
done();
|
||||
});
|
||||
const event = new MapBrowserEvent('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -50,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
const event = new MapBrowserEvent('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -50,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
it('works on other browsers (wheel)', function(done) {
|
||||
const origHasSafari = _ol_has_.SAFARI;
|
||||
_ol_has_.SAFARI = false;
|
||||
map.once('postrender', function() {
|
||||
const call = Interaction.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
_ol_has_.SAFARI = origHasSafari;
|
||||
done();
|
||||
if (!SAFARI) {
|
||||
it('works on other browsers (wheel)', function(done) {
|
||||
map.once('postrender', function() {
|
||||
const call = Interaction.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
done();
|
||||
});
|
||||
const event = new MapBrowserEvent('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -120,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
const event = new MapBrowserEvent('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -120,
|
||||
target: map.getViewport(),
|
||||
preventDefault: Event.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import MapEvent from '../../../src/ol/MapEvent.js';
|
||||
import Overlay from '../../../src/ol/Overlay.js';
|
||||
import View from '../../../src/ol/View.js';
|
||||
import LineString from '../../../src/ol/geom/LineString.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import {TOUCH} from '../../../src/ol/has.js';
|
||||
import {defaults as defaultInteractions} from '../../../src/ol/interaction.js';
|
||||
import DoubleClickZoom from '../../../src/ol/interaction/DoubleClickZoom.js';
|
||||
import Interaction from '../../../src/ol/interaction/Interaction.js';
|
||||
@@ -38,7 +38,7 @@ describe('ol.Map', function() {
|
||||
it('creates the viewport', function() {
|
||||
const map = new Map({});
|
||||
const viewport = map.getViewport();
|
||||
const className = 'ol-viewport' + (_ol_has_.TOUCH ? ' ol-touch' : '');
|
||||
const className = 'ol-viewport' + (TOUCH ? ' ol-touch' : '');
|
||||
expect(viewport.className).to.be(className);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Map from '../../../src/ol/Map.js';
|
||||
import MapBrowserEventHandler from '../../../src/ol/MapBrowserEventHandler.js';
|
||||
import {listen} from '../../../src/ol/events.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import {DEVICE_PIXEL_RATIO} from '../../../src/ol/has.js';
|
||||
import PointerEvent from '../../../src/ol/pointer/PointerEvent.js';
|
||||
|
||||
describe('ol.MapBrowserEventHandler', function() {
|
||||
@@ -139,32 +139,32 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
|
||||
it('is moving if distance is 2', function() {
|
||||
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
||||
clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1
|
||||
clientX: DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: DEVICE_PIXEL_RATIO + 1
|
||||
});
|
||||
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
||||
});
|
||||
|
||||
it('is moving with negative distance', function() {
|
||||
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
||||
clientX: -(_ol_has_.DEVICE_PIXEL_RATIO + 1),
|
||||
clientY: -(_ol_has_.DEVICE_PIXEL_RATIO + 1)
|
||||
clientX: -(DEVICE_PIXEL_RATIO + 1),
|
||||
clientY: -(DEVICE_PIXEL_RATIO + 1)
|
||||
});
|
||||
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
||||
});
|
||||
|
||||
it('is not moving if distance is less than move tolerance', function() {
|
||||
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
||||
clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1
|
||||
clientX: DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: DEVICE_PIXEL_RATIO + 1
|
||||
});
|
||||
expect(moveToleranceHandler.isMoving_(pointerdownAt2)).to.be(false);
|
||||
});
|
||||
|
||||
it('is moving if distance is greater than move tolerance', function() {
|
||||
const pointerdownAt9 = new PointerEvent('pointerdown', {}, {
|
||||
clientX: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1,
|
||||
clientY: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1
|
||||
clientX: (DEVICE_PIXEL_RATIO * 8) + 1,
|
||||
clientY: (DEVICE_PIXEL_RATIO * 8) + 1
|
||||
});
|
||||
expect(moveToleranceHandler.isMoving_(pointerdownAt9)).to.be(true);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
|
||||
import TouchSource from '../../../../src/ol/pointer/TouchSource.js';
|
||||
import MouseSource from '../../../../src/ol/pointer/MouseSource.js';
|
||||
import MsSource from '../../../../src/ol/pointer/MsSource.js';
|
||||
import NativeSource from '../../../../src/ol/pointer/NativeSource.js';
|
||||
|
||||
|
||||
describe('ol.pointer.MouseSource', function() {
|
||||
@@ -16,11 +18,31 @@ describe('ol.pointer.MouseSource', function() {
|
||||
target = new EventTarget();
|
||||
|
||||
// make sure that a mouse and touch event source is used
|
||||
_ol_has_.POINTER = false;
|
||||
_ol_has_.MSPOINTER = false;
|
||||
_ol_has_.TOUCH = true;
|
||||
const POINTER = false;
|
||||
const MSPOINTER = false;
|
||||
const TOUCH = true;
|
||||
const originalRegisterSources = PointerEventHandler.prototype.registerSources;
|
||||
PointerEventHandler.prototype.registerSources = function() {
|
||||
if (POINTER) {
|
||||
this.registerSource('native', new NativeSource(this));
|
||||
} else if (MSPOINTER) {
|
||||
this.registerSource('ms', new MsSource(this));
|
||||
} else {
|
||||
const mouseSource = new MouseSource(this);
|
||||
this.registerSource('mouse', mouseSource);
|
||||
|
||||
if (TOUCH) {
|
||||
this.registerSource('touch', new TouchSource(this, mouseSource));
|
||||
}
|
||||
}
|
||||
|
||||
// register events on the viewport element
|
||||
this.register_();
|
||||
};
|
||||
|
||||
handler = new PointerEventHandler(target);
|
||||
PointerEventHandler.prototype.registerSources = originalRegisterSources;
|
||||
|
||||
eventSpy = sinon.spy();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import MouseSource from '../../../../src/ol/pointer/MouseSource.js';
|
||||
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
|
||||
import TouchSource from '../../../../src/ol/pointer/TouchSource.js';
|
||||
import MsSource from '../../../../src/ol/pointer/MsSource.js';
|
||||
import NativeSource from '../../../../src/ol/pointer/NativeSource.js';
|
||||
|
||||
|
||||
describe('ol.pointer.PointerEventHandler', function() {
|
||||
@@ -15,10 +17,31 @@ describe('ol.pointer.PointerEventHandler', function() {
|
||||
target = new EventTarget();
|
||||
|
||||
// make sure that a mouse event source is used
|
||||
_ol_has_.POINTER = false;
|
||||
_ol_has_.MSPOINTER = false;
|
||||
const POINTER = false;
|
||||
const MSPOINTER = false;
|
||||
const TOUCH = false;
|
||||
const originalRegisterSources = PointerEventHandler.prototype.registerSources;
|
||||
PointerEventHandler.prototype.registerSources = function() {
|
||||
if (POINTER) {
|
||||
this.registerSource('native', new NativeSource(this));
|
||||
} else if (MSPOINTER) {
|
||||
this.registerSource('ms', new MsSource(this));
|
||||
} else {
|
||||
const mouseSource = new MouseSource(this);
|
||||
this.registerSource('mouse', mouseSource);
|
||||
|
||||
if (TOUCH) {
|
||||
this.registerSource('touch', new TouchSource(this, mouseSource));
|
||||
}
|
||||
}
|
||||
|
||||
// register events on the viewport element
|
||||
this.register_();
|
||||
};
|
||||
|
||||
handler = new PointerEventHandler(target);
|
||||
PointerEventHandler.prototype.registerSources = originalRegisterSources;
|
||||
|
||||
eventSpy = sinon.spy();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import Event from '../../../../src/ol/events/Event.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import {assign} from '../../../../src/ol/obj.js';
|
||||
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
|
||||
import TouchSource from '../../../../src/ol/pointer/TouchSource.js';
|
||||
import MouseSource from '../../../../src/ol/pointer/MouseSource.js';
|
||||
import MsSource from '../../../../src/ol/pointer/MsSource.js';
|
||||
import NativeSource from '../../../../src/ol/pointer/NativeSource.js';
|
||||
|
||||
describe('ol.pointer.TouchSource', function() {
|
||||
let handler;
|
||||
@@ -14,11 +17,31 @@ describe('ol.pointer.TouchSource', function() {
|
||||
target = new EventTarget();
|
||||
|
||||
// make sure that a mouse and touch event source is used
|
||||
_ol_has_.POINTER = false;
|
||||
_ol_has_.MSPOINTER = false;
|
||||
_ol_has_.TOUCH = true;
|
||||
const POINTER = false;
|
||||
const MSPOINTER = false;
|
||||
const TOUCH = true;
|
||||
const originalRegisterSources = PointerEventHandler.prototype.registerSources;
|
||||
PointerEventHandler.prototype.registerSources = function() {
|
||||
if (POINTER) {
|
||||
this.registerSource('native', new NativeSource(this));
|
||||
} else if (MSPOINTER) {
|
||||
this.registerSource('ms', new MsSource(this));
|
||||
} else {
|
||||
const mouseSource = new MouseSource(this);
|
||||
this.registerSource('mouse', mouseSource);
|
||||
|
||||
if (TOUCH) {
|
||||
this.registerSource('touch', new TouchSource(this, mouseSource));
|
||||
}
|
||||
}
|
||||
|
||||
// register events on the viewport element
|
||||
this.register_();
|
||||
};
|
||||
|
||||
handler = new PointerEventHandler(target);
|
||||
PointerEventHandler.prototype.registerSources = originalRegisterSources;
|
||||
|
||||
eventSpy = sinon.spy();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {equals} from '../../../src/ol/array.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import {DEVICE_PIXEL_RATIO} from '../../../src/ol/has.js';
|
||||
import {toContext} from '../../../src/ol/render.js';
|
||||
import CanvasImmediateRenderer from '../../../src/ol/render/canvas/Immediate.js';
|
||||
import _ol_transform_ from '../../../src/ol/transform.js';
|
||||
@@ -13,7 +13,7 @@ describe('ol.render', function() {
|
||||
const canvas = document.createElement('canvas');
|
||||
const render = toContext(canvas.getContext('2d'));
|
||||
expect(render).to.be.a(CanvasImmediateRenderer);
|
||||
expect(render.pixelRatio_).to.be(_ol_has_.DEVICE_PIXEL_RATIO);
|
||||
expect(render.pixelRatio_).to.be(DEVICE_PIXEL_RATIO);
|
||||
});
|
||||
|
||||
it('sets size and pixel ratio from options', function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {equals} from '../src/ol/array.js';
|
||||
import _ol_has_ from '../src/ol/has.js';
|
||||
import {WEBGL} from '../src/ol/has.js';
|
||||
// avoid importing anything that results in an instanceof check
|
||||
// since these extensions are global, instanceof checks fail with modules
|
||||
|
||||
@@ -377,7 +377,7 @@ import _ol_has_ from '../src/ol/has.js';
|
||||
};
|
||||
|
||||
global.assertWebGL = function(map) {
|
||||
if (!_ol_has_.WEBGL) {
|
||||
if (!WEBGL) {
|
||||
expect().fail('No WebGL support!');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user