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 View from '../src/ol/View.js';
|
||||||
import * as _ol_extent_ from '../src/ol/extent.js';
|
import * as _ol_extent_ from '../src/ol/extent.js';
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.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 VectorLayer from '../src/ol/layer/Vector.js';
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
import {fromLonLat} from '../src/ol/proj.js';
|
||||||
import VectorSource from '../src/ol/source/Vector.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
|
// Gradient and pattern are in canvas pixel space, so we adjust for the
|
||||||
// renderer's pixel ratio
|
// renderer's pixel ratio
|
||||||
const pixelRatio = _ol_has_.DEVICE_PIXEL_RATIO;
|
const pixelRatio = DEVICE_PIXEL_RATIO;
|
||||||
|
|
||||||
// Generate a rainbow gradient
|
// Generate a rainbow gradient
|
||||||
function gradient(feature, resolution) {
|
function gradient(feature, resolution) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import View from '../src/ol/View.js';
|
import View from '../src/ol/View.js';
|
||||||
import {defaults as defaultControls} from '../src/ol/control.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 TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
import OSM from '../src/ol/source/OSM.js';
|
||||||
|
|
||||||
if (!_ol_has_.WEBGL) {
|
if (!WEBGL) {
|
||||||
const info = document.getElementById('no-webgl');
|
const info = document.getElementById('no-webgl');
|
||||||
/**
|
/**
|
||||||
* display error message
|
* display error message
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import View from '../src/ol/View.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 TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
import OSM from '../src/ol/source/OSM.js';
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ const map1 = new Map({
|
|||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_ol_has_.WEBGL) {
|
if (WEBGL) {
|
||||||
const map2 = new Map({
|
const map2 = new Map({
|
||||||
target: 'webglMap',
|
target: 'webglMap',
|
||||||
renderer: /** @type {Array<ol.renderer.Type>} */ (['webgl', 'canvas']),
|
renderer: /** @type {Array<ol.renderer.Type>} */ (['webgl', 'canvas']),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import View from '../src/ol/View.js';
|
import View from '../src/ol/View.js';
|
||||||
import WMTSCapabilities from '../src/ol/format/WMTSCapabilities.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 TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import WMTS from '../src/ol/source/WMTS.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:
|
// HiDPI support:
|
||||||
// * Use 'bmaphidpi' layer (pixel ratio 2) for device pixel ratio > 1
|
// * Use 'bmaphidpi' layer (pixel ratio 2) for device pixel ratio > 1
|
||||||
// * Use 'geolandbasemap' layer (pixel ratio 1) 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 layer = hiDPI ? 'bmaphidpi' : 'geolandbasemap';
|
||||||
const tilePixelRatio = hiDPI ? 2 : 1;
|
const tilePixelRatio = hiDPI ? 2 : 1;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import BaseObject from './Object.js';
|
|||||||
import {listen} from './events.js';
|
import {listen} from './events.js';
|
||||||
import EventType from './events/EventType.js';
|
import EventType from './events/EventType.js';
|
||||||
import {circular as circularPolygon} from './geom/Polygon.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 {toRadians} from './math.js';
|
||||||
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
|
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ Geolocation.prototype.handleProjectionChanged_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Geolocation.prototype.handleTrackingChanged_ = function() {
|
Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||||
if (_ol_has_.GEOLOCATION) {
|
if (GEOLOCATION) {
|
||||||
const tracking = this.getTracking();
|
const tracking = this.getTracking();
|
||||||
if (tracking && this.watchId_ === undefined) {
|
if (tracking && this.watchId_ === undefined) {
|
||||||
this.watchId_ = navigator.geolocation.watchPosition(
|
this.watchId_ = navigator.geolocation.watchPosition(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @module ol/MapBrowserEventHandler
|
* @module ol/MapBrowserEventHandler
|
||||||
*/
|
*/
|
||||||
import {inherits} from './index.js';
|
import {inherits} from './index.js';
|
||||||
import _ol_has_ from './has.js';
|
import {DEVICE_PIXEL_RATIO} from './has.js';
|
||||||
import MapBrowserEventType from './MapBrowserEventType.js';
|
import MapBrowserEventType from './MapBrowserEventType.js';
|
||||||
import MapBrowserPointerEvent from './MapBrowserPointerEvent.js';
|
import MapBrowserPointerEvent from './MapBrowserPointerEvent.js';
|
||||||
import {listen, unlistenByKey} from './events.js';
|
import {listen, unlistenByKey} from './events.js';
|
||||||
@@ -50,7 +50,7 @@ const MapBrowserEventHandler = function(map, moveTolerance) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.moveTolerance_ = moveTolerance ?
|
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).
|
* 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 EventType from './events/EventType.js';
|
||||||
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
|
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
|
||||||
import {TRUE} from './functions.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 LayerGroup from './layer/Group.js';
|
||||||
import {getMapRendererPlugins} from './plugins.js';
|
import {getMapRendererPlugins} from './plugins.js';
|
||||||
import RendererType from './renderer/Type.js';
|
import RendererType from './renderer/Type.js';
|
||||||
@@ -136,7 +136,7 @@ const PluggableMap = function(options) {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.pixelRatio_ = options.pixelRatio !== undefined ?
|
this.pixelRatio_ = options.pixelRatio !== undefined ?
|
||||||
options.pixelRatio : _ol_has_.DEVICE_PIXEL_RATIO;
|
options.pixelRatio : DEVICE_PIXEL_RATIO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -206,7 +206,7 @@ const PluggableMap = function(options) {
|
|||||||
* @type {Element}
|
* @type {Element}
|
||||||
*/
|
*/
|
||||||
this.viewport_ = document.createElement('DIV');
|
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.position = 'relative';
|
||||||
this.viewport_.style.overflow = 'hidden';
|
this.viewport_.style.overflow = 'hidden';
|
||||||
this.viewport_.style.width = '100%';
|
this.viewport_.style.width = '100%';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import {TRUE, FALSE} from '../functions.js';
|
import {TRUE, FALSE} from '../functions.js';
|
||||||
import _ol_has_ from '../has.js';
|
import {WEBKIT, MAC} from '../has.js';
|
||||||
const _ol_events_condition_ = {};
|
const _ol_events_condition_ = {};
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ _ol_events_condition_.click = function(mapBrowserEvent) {
|
|||||||
_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) {
|
_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) {
|
||||||
const originalEvent = mapBrowserEvent.originalEvent;
|
const originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return originalEvent.button == 0 &&
|
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) {
|
_ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
|
||||||
const originalEvent = mapBrowserEvent.originalEvent;
|
const originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return !originalEvent.altKey &&
|
return !originalEvent.altKey &&
|
||||||
(_ol_has_.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
(MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
||||||
!originalEvent.shiftKey;
|
!originalEvent.shiftKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
import {HAS_WEBGL} from './index.js';
|
import {HAS_WEBGL} from './index.js';
|
||||||
|
|
||||||
const _ol_has_ = {};
|
|
||||||
|
|
||||||
const ua = typeof navigator !== 'undefined' ?
|
const ua = typeof navigator !== 'undefined' ?
|
||||||
navigator.userAgent.toLowerCase() : '';
|
navigator.userAgent.toLowerCase() : '';
|
||||||
|
|
||||||
@@ -12,25 +10,25 @@ const ua = typeof navigator !== 'undefined' ?
|
|||||||
* User agent string says we are dealing with Firefox as browser.
|
* User agent string says we are dealing with Firefox as browser.
|
||||||
* @type {boolean}
|
* @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.
|
* User agent string says we are dealing with Safari as browser.
|
||||||
* @type {boolean}
|
* @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.
|
* User agent string says we are dealing with a WebKit engine.
|
||||||
* @type {boolean}
|
* @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.
|
* User agent string says we are dealing with a Mac as platform.
|
||||||
* @type {boolean}
|
* @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}
|
* @type {number}
|
||||||
* @api
|
* @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.
|
* True if the browser's Canvas implementation implements {get,set}LineDash.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
_ol_has_.CANVAS_LINE_DASH = false;
|
export const CANVAS_LINE_DASH = function() {
|
||||||
|
let has = false;
|
||||||
|
try {
|
||||||
/**
|
has = !!document.createElement('CANVAS').getContext('2d').setLineDash;
|
||||||
* True if the and browsers support Canvas.
|
} catch (e) {
|
||||||
* @const
|
// pass
|
||||||
* @type {boolean}
|
}
|
||||||
* @api
|
return has;
|
||||||
*/
|
}();
|
||||||
_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;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +62,7 @@ _ol_has_.CANVAS = (
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @api
|
* @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}
|
* @type {boolean}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_has_.TOUCH = 'ontouchstart' in window;
|
export const TOUCH = 'ontouchstart' in window;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +79,7 @@ _ol_has_.TOUCH = 'ontouchstart' in window;
|
|||||||
* @const
|
* @const
|
||||||
* @type {boolean}
|
* @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
|
* @const
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
_ol_has_.MSPOINTER = !!(navigator.msPointerEnabled);
|
export const MSPOINTER = !!(navigator.msPointerEnabled);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +96,4 @@ _ol_has_.MSPOINTER = !!(navigator.msPointerEnabled);
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_has_.WEBGL = HAS_WEBGL;
|
export const WEBGL = HAS_WEBGL;
|
||||||
|
|
||||||
|
|
||||||
export default _ol_has_;
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import ViewHint from '../ViewHint.js';
|
|||||||
import condition from '../events/condition.js';
|
import condition from '../events/condition.js';
|
||||||
import {easeOut} from '../easing.js';
|
import {easeOut} from '../easing.js';
|
||||||
import EventType from '../events/EventType.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 Interaction from '../interaction/Interaction.js';
|
||||||
import {clamp} from '../math.js';
|
import {clamp} from '../math.js';
|
||||||
|
|
||||||
@@ -156,16 +156,16 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
let delta;
|
let delta;
|
||||||
if (mapBrowserEvent.type == EventType.WHEEL) {
|
if (mapBrowserEvent.type == EventType.WHEEL) {
|
||||||
delta = wheelEvent.deltaY;
|
delta = wheelEvent.deltaY;
|
||||||
if (_ol_has_.FIREFOX &&
|
if (FIREFOX &&
|
||||||
wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
||||||
delta /= _ol_has_.DEVICE_PIXEL_RATIO;
|
delta /= DEVICE_PIXEL_RATIO;
|
||||||
}
|
}
|
||||||
if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
||||||
delta *= 40;
|
delta *= 40;
|
||||||
}
|
}
|
||||||
} else if (mapBrowserEvent.type == EventType.MOUSEWHEEL) {
|
} else if (mapBrowserEvent.type == EventType.MOUSEWHEEL) {
|
||||||
delta = -wheelEvent.wheelDeltaY;
|
delta = -wheelEvent.wheelDeltaY;
|
||||||
if (_ol_has_.SAFARI) {
|
if (SAFARI) {
|
||||||
delta /= 3;
|
delta /= 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
import {inherits} from '../index.js';
|
import {inherits} from '../index.js';
|
||||||
import {listen, unlisten} from '../events.js';
|
import {listen, unlisten} from '../events.js';
|
||||||
import EventTarget from '../events/EventTarget.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 PointerEventType from '../pointer/EventType.js';
|
||||||
import MouseSource from '../pointer/MouseSource.js';
|
import MouseSource from '../pointer/MouseSource.js';
|
||||||
import MsSource from '../pointer/MsSource.js';
|
import MsSource from '../pointer/MsSource.js';
|
||||||
@@ -86,15 +86,15 @@ inherits(PointerEventHandler, EventTarget);
|
|||||||
* that generate pointer events.
|
* that generate pointer events.
|
||||||
*/
|
*/
|
||||||
PointerEventHandler.prototype.registerSources = function() {
|
PointerEventHandler.prototype.registerSources = function() {
|
||||||
if (_ol_has_.POINTER) {
|
if (POINTER) {
|
||||||
this.registerSource('native', new NativeSource(this));
|
this.registerSource('native', new NativeSource(this));
|
||||||
} else if (_ol_has_.MSPOINTER) {
|
} else if (MSPOINTER) {
|
||||||
this.registerSource('ms', new MsSource(this));
|
this.registerSource('ms', new MsSource(this));
|
||||||
} else {
|
} else {
|
||||||
const mouseSource = new MouseSource(this);
|
const mouseSource = new MouseSource(this);
|
||||||
this.registerSource('mouse', mouseSource);
|
this.registerSource('mouse', mouseSource);
|
||||||
|
|
||||||
if (_ol_has_.TOUCH) {
|
if (TOUCH) {
|
||||||
this.registerSource('touch', new TouchSource(this, mouseSource));
|
this.registerSource('touch', new TouchSource(this, mouseSource));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/render
|
* @module ol/render
|
||||||
*/
|
*/
|
||||||
import _ol_has_ from './has.js';
|
import {DEVICE_PIXEL_RATIO} from './has.js';
|
||||||
import _ol_transform_ from './transform.js';
|
import _ol_transform_ from './transform.js';
|
||||||
import CanvasImmediateRenderer from './render/canvas/Immediate.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) {
|
export function toContext(context, opt_options) {
|
||||||
const canvas = context.canvas;
|
const canvas = context.canvas;
|
||||||
const options = opt_options ? opt_options : {};
|
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;
|
const size = options.size;
|
||||||
if (size) {
|
if (size) {
|
||||||
canvas.width = size[0] * pixelRatio;
|
canvas.width = size[0] * pixelRatio;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {intersects} from '../../extent.js';
|
|||||||
import GeometryType from '../../geom/GeometryType.js';
|
import GeometryType from '../../geom/GeometryType.js';
|
||||||
import SimpleGeometry from '../../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.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 VectorContext from '../VectorContext.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
import _ol_transform_ from '../../transform.js';
|
import _ol_transform_ from '../../transform.js';
|
||||||
@@ -728,7 +728,7 @@ CanvasImmediateRenderer.prototype.setContextStrokeState_ = function(strokeState)
|
|||||||
const contextStrokeState = this.contextStrokeState_;
|
const contextStrokeState = this.contextStrokeState_;
|
||||||
if (!contextStrokeState) {
|
if (!contextStrokeState) {
|
||||||
context.lineCap = strokeState.lineCap;
|
context.lineCap = strokeState.lineCap;
|
||||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
if (CANVAS_LINE_DASH) {
|
||||||
context.setLineDash(strokeState.lineDash);
|
context.setLineDash(strokeState.lineDash);
|
||||||
context.lineDashOffset = strokeState.lineDashOffset;
|
context.lineDashOffset = strokeState.lineDashOffset;
|
||||||
}
|
}
|
||||||
@@ -749,7 +749,7 @@ CanvasImmediateRenderer.prototype.setContextStrokeState_ = function(strokeState)
|
|||||||
if (contextStrokeState.lineCap != strokeState.lineCap) {
|
if (contextStrokeState.lineCap != strokeState.lineCap) {
|
||||||
contextStrokeState.lineCap = context.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)) {
|
if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {
|
||||||
context.setLineDash(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_length_ from '../../geom/flat/length.js';
|
||||||
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
|
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.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 {isEmpty} from '../../obj.js';
|
||||||
import VectorContext from '../VectorContext.js';
|
import VectorContext from '../VectorContext.js';
|
||||||
import _ol_render_canvas_ from '../canvas.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.lineCap = /** @type {string} */ (instruction[3]);
|
||||||
context.lineJoin = /** @type {string} */ (instruction[4]);
|
context.lineJoin = /** @type {string} */ (instruction[4]);
|
||||||
context.miterLimit = /** @type {number} */ (instruction[5]);
|
context.miterLimit = /** @type {number} */ (instruction[5]);
|
||||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
if (CANVAS_LINE_DASH) {
|
||||||
context.lineDashOffset = /** @type {number} */ (instruction[7]);
|
context.lineDashOffset = /** @type {number} */ (instruction[7]);
|
||||||
context.setLineDash(/** @type {Array.<number>} */ (instruction[6]));
|
context.setLineDash(/** @type {Array.<number>} */ (instruction[6]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {createCanvasContext2D} from '../../dom.js';
|
|||||||
import {intersects} from '../../extent.js';
|
import {intersects} from '../../extent.js';
|
||||||
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
||||||
import GeometryType from '../../geom/GeometryType.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 _ol_render_canvas_ from '../canvas.js';
|
||||||
import CanvasInstruction from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import CanvasReplay from '../canvas/Replay.js';
|
import CanvasReplay from '../canvas/Replay.js';
|
||||||
@@ -314,11 +314,11 @@ CanvasTextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey
|
|||||||
context.font = textState.font;
|
context.font = textState.font;
|
||||||
if (strokeKey) {
|
if (strokeKey) {
|
||||||
context.strokeStyle = strokeState.strokeStyle;
|
context.strokeStyle = strokeState.strokeStyle;
|
||||||
context.lineWidth = strokeWidth * (_ol_has_.SAFARI ? scale : 1);
|
context.lineWidth = strokeWidth * (SAFARI ? scale : 1);
|
||||||
context.lineCap = strokeState.lineCap;
|
context.lineCap = strokeState.lineCap;
|
||||||
context.lineJoin = strokeState.lineJoin;
|
context.lineJoin = strokeState.lineJoin;
|
||||||
context.miterLimit = strokeState.miterLimit;
|
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.setLineDash(strokeState.lineDash);
|
||||||
context.lineDashOffset = strokeState.lineDashOffset;
|
context.lineDashOffset = strokeState.lineDashOffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js';
|
|||||||
import {asColorLike} from '../../colorlike.js';
|
import {asColorLike} from '../../colorlike.js';
|
||||||
import {createCanvasContext2D} from '../../dom.js';
|
import {createCanvasContext2D} from '../../dom.js';
|
||||||
import GeometryType from '../../geom/GeometryType.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_replay_ from '../replay.js';
|
||||||
import _ol_render_webgl_ from '../webgl.js';
|
import _ol_render_webgl_ from '../webgl.js';
|
||||||
import WebGLTextureReplay from '../webgl/TextureReplay.js';
|
import WebGLTextureReplay from '../webgl/TextureReplay.js';
|
||||||
@@ -269,7 +269,7 @@ WebGLTextReplay.prototype.addCharToAtlas_ = function(char) {
|
|||||||
ctx.miterLimit = /** @type {number} */ (state.miterLimit);
|
ctx.miterLimit = /** @type {number} */ (state.miterLimit);
|
||||||
ctx.textAlign = 'left';
|
ctx.textAlign = 'left';
|
||||||
ctx.textBaseline = 'top';
|
ctx.textBaseline = 'top';
|
||||||
if (_ol_has_.CANVAS_LINE_DASH && state.lineDash) {
|
if (CANVAS_LINE_DASH && state.lineDash) {
|
||||||
//FIXME: use pixelRatio
|
//FIXME: use pixelRatio
|
||||||
ctx.setLineDash(state.lineDash);
|
ctx.setLineDash(state.lineDash);
|
||||||
ctx.lineDashOffset = /** @type {number} */ (state.lineDashOffset);
|
ctx.lineDashOffset = /** @type {number} */ (state.lineDashOffset);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {stableSort} from '../../array.js';
|
|||||||
import {CLASS_UNSELECTABLE} from '../../css.js';
|
import {CLASS_UNSELECTABLE} from '../../css.js';
|
||||||
import {createCanvasContext2D} from '../../dom.js';
|
import {createCanvasContext2D} from '../../dom.js';
|
||||||
import {listen} from '../../events.js';
|
import {listen} from '../../events.js';
|
||||||
import _ol_has_ from '../../has.js';
|
import {WEBGL} from '../../has.js';
|
||||||
import Layer from '../../layer/Layer.js';
|
import Layer from '../../layer/Layer.js';
|
||||||
import RenderEvent from '../../render/Event.js';
|
import RenderEvent from '../../render/Event.js';
|
||||||
import RenderEventType from '../../render/EventType.js';
|
import RenderEventType from '../../render/EventType.js';
|
||||||
@@ -175,7 +175,7 @@ inherits(WebGLMapRenderer, MapRenderer);
|
|||||||
* @return {boolean} The renderer can render the layer.
|
* @return {boolean} The renderer can render the layer.
|
||||||
*/
|
*/
|
||||||
WebGLMapRenderer['handles'] = function(type) {
|
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 {inherits} from '../index.js';
|
||||||
import {asColorLike} from '../colorlike.js';
|
import {asColorLike} from '../colorlike.js';
|
||||||
import {createCanvasContext2D} from '../dom.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 ImageState from '../ImageState.js';
|
||||||
import _ol_render_canvas_ from '../render/canvas.js';
|
import _ol_render_canvas_ from '../render/canvas.js';
|
||||||
import ImageStyle from '../style/Image.js';
|
import ImageStyle from '../style/Image.js';
|
||||||
@@ -334,7 +334,7 @@ RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
}
|
}
|
||||||
lineDash = this.stroke_.getLineDash();
|
lineDash = this.stroke_.getLineDash();
|
||||||
lineDashOffset = this.stroke_.getLineDashOffset();
|
lineDashOffset = this.stroke_.getLineDashOffset();
|
||||||
if (!_ol_has_.CANVAS_LINE_DASH) {
|
if (!CANVAS_LINE_DASH) {
|
||||||
lineDash = null;
|
lineDash = null;
|
||||||
lineDashOffset = 0;
|
lineDashOffset = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Map from '../../../../src/ol/Map.js';
|
|||||||
import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
|
import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import Event from '../../../../src/ol/events/Event.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 Interaction from '../../../../src/ol/interaction/Interaction.js';
|
||||||
import MouseWheelZoom from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
import MouseWheelZoom from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
||||||
|
|
||||||
@@ -62,43 +62,41 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
|||||||
|
|
||||||
describe('handleEvent()', function() {
|
describe('handleEvent()', function() {
|
||||||
|
|
||||||
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
if (FIREFOX) {
|
||||||
const origHasFirefox = _ol_has_.FIREFOX;
|
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||||
_ol_has_.FIREFOX = true;
|
map.once('postrender', function() {
|
||||||
map.once('postrender', function() {
|
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||||
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
done();
|
||||||
_ol_has_.FIREFOX = origHasFirefox;
|
});
|
||||||
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) {
|
if (!FIREFOX) {
|
||||||
const origHasFirefox = _ol_has_.FIREFOX;
|
it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||||
_ol_has_.FIREFOX = false;
|
map.once('postrender', function() {
|
||||||
map.once('postrender', function() {
|
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||||
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
done();
|
||||||
_ol_has_.FIREFOX = origHasFirefox;
|
});
|
||||||
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() {
|
describe('spying on ol.interaction.Interaction.zoomByDelta', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -126,45 +124,43 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
|||||||
map.handleMapBrowserEvent(event);
|
map.handleMapBrowserEvent(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works on Safari (wheel)', function(done) {
|
if (SAFARI) {
|
||||||
const origHasSafari = _ol_has_.SAFARI;
|
it('works on Safari (wheel)', function(done) {
|
||||||
_ol_has_.SAFARI = true;
|
map.once('postrender', function() {
|
||||||
map.once('postrender', function() {
|
const call = Interaction.zoomByDelta.getCall(0);
|
||||||
const call = Interaction.zoomByDelta.getCall(0);
|
expect(call.args[1]).to.be(-1);
|
||||||
expect(call.args[1]).to.be(-1);
|
expect(call.args[2]).to.eql([0, 0]);
|
||||||
expect(call.args[2]).to.eql([0, 0]);
|
done();
|
||||||
_ol_has_.SAFARI = origHasSafari;
|
});
|
||||||
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) {
|
if (!SAFARI) {
|
||||||
const origHasSafari = _ol_has_.SAFARI;
|
it('works on other browsers (wheel)', function(done) {
|
||||||
_ol_has_.SAFARI = false;
|
map.once('postrender', function() {
|
||||||
map.once('postrender', function() {
|
const call = Interaction.zoomByDelta.getCall(0);
|
||||||
const call = Interaction.zoomByDelta.getCall(0);
|
expect(call.args[1]).to.be(-1);
|
||||||
expect(call.args[1]).to.be(-1);
|
expect(call.args[2]).to.eql([0, 0]);
|
||||||
expect(call.args[2]).to.eql([0, 0]);
|
done();
|
||||||
_ol_has_.SAFARI = origHasSafari;
|
});
|
||||||
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 Overlay from '../../../src/ol/Overlay.js';
|
||||||
import View from '../../../src/ol/View.js';
|
import View from '../../../src/ol/View.js';
|
||||||
import LineString from '../../../src/ol/geom/LineString.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 {defaults as defaultInteractions} from '../../../src/ol/interaction.js';
|
||||||
import DoubleClickZoom from '../../../src/ol/interaction/DoubleClickZoom.js';
|
import DoubleClickZoom from '../../../src/ol/interaction/DoubleClickZoom.js';
|
||||||
import Interaction from '../../../src/ol/interaction/Interaction.js';
|
import Interaction from '../../../src/ol/interaction/Interaction.js';
|
||||||
@@ -38,7 +38,7 @@ describe('ol.Map', function() {
|
|||||||
it('creates the viewport', function() {
|
it('creates the viewport', function() {
|
||||||
const map = new Map({});
|
const map = new Map({});
|
||||||
const viewport = map.getViewport();
|
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);
|
expect(viewport.className).to.be(className);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Map from '../../../src/ol/Map.js';
|
import Map from '../../../src/ol/Map.js';
|
||||||
import MapBrowserEventHandler from '../../../src/ol/MapBrowserEventHandler.js';
|
import MapBrowserEventHandler from '../../../src/ol/MapBrowserEventHandler.js';
|
||||||
import {listen} from '../../../src/ol/events.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';
|
import PointerEvent from '../../../src/ol/pointer/PointerEvent.js';
|
||||||
|
|
||||||
describe('ol.MapBrowserEventHandler', function() {
|
describe('ol.MapBrowserEventHandler', function() {
|
||||||
@@ -139,32 +139,32 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
|
|
||||||
it('is moving if distance is 2', function() {
|
it('is moving if distance is 2', function() {
|
||||||
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
||||||
clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1,
|
clientX: DEVICE_PIXEL_RATIO + 1,
|
||||||
clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1
|
clientY: DEVICE_PIXEL_RATIO + 1
|
||||||
});
|
});
|
||||||
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is moving with negative distance', function() {
|
it('is moving with negative distance', function() {
|
||||||
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
||||||
clientX: -(_ol_has_.DEVICE_PIXEL_RATIO + 1),
|
clientX: -(DEVICE_PIXEL_RATIO + 1),
|
||||||
clientY: -(_ol_has_.DEVICE_PIXEL_RATIO + 1)
|
clientY: -(DEVICE_PIXEL_RATIO + 1)
|
||||||
});
|
});
|
||||||
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is not moving if distance is less than move tolerance', function() {
|
it('is not moving if distance is less than move tolerance', function() {
|
||||||
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
const pointerdownAt2 = new PointerEvent('pointerdown', {}, {
|
||||||
clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1,
|
clientX: DEVICE_PIXEL_RATIO + 1,
|
||||||
clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1
|
clientY: DEVICE_PIXEL_RATIO + 1
|
||||||
});
|
});
|
||||||
expect(moveToleranceHandler.isMoving_(pointerdownAt2)).to.be(false);
|
expect(moveToleranceHandler.isMoving_(pointerdownAt2)).to.be(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is moving if distance is greater than move tolerance', function() {
|
it('is moving if distance is greater than move tolerance', function() {
|
||||||
const pointerdownAt9 = new PointerEvent('pointerdown', {}, {
|
const pointerdownAt9 = new PointerEvent('pointerdown', {}, {
|
||||||
clientX: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1,
|
clientX: (DEVICE_PIXEL_RATIO * 8) + 1,
|
||||||
clientY: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1
|
clientY: (DEVICE_PIXEL_RATIO * 8) + 1
|
||||||
});
|
});
|
||||||
expect(moveToleranceHandler.isMoving_(pointerdownAt9)).to.be(true);
|
expect(moveToleranceHandler.isMoving_(pointerdownAt9)).to.be(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import {listen} from '../../../../src/ol/events.js';
|
import {listen} from '../../../../src/ol/events.js';
|
||||||
import EventTarget from '../../../../src/ol/events/EventTarget.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 PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
|
||||||
import TouchSource from '../../../../src/ol/pointer/TouchSource.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() {
|
describe('ol.pointer.MouseSource', function() {
|
||||||
@@ -16,11 +18,31 @@ describe('ol.pointer.MouseSource', function() {
|
|||||||
target = new EventTarget();
|
target = new EventTarget();
|
||||||
|
|
||||||
// make sure that a mouse and touch event source is used
|
// make sure that a mouse and touch event source is used
|
||||||
_ol_has_.POINTER = false;
|
const POINTER = false;
|
||||||
_ol_has_.MSPOINTER = false;
|
const MSPOINTER = false;
|
||||||
_ol_has_.TOUCH = true;
|
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);
|
handler = new PointerEventHandler(target);
|
||||||
|
PointerEventHandler.prototype.registerSources = originalRegisterSources;
|
||||||
|
|
||||||
eventSpy = sinon.spy();
|
eventSpy = sinon.spy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import {listen} from '../../../../src/ol/events.js';
|
import {listen} from '../../../../src/ol/events.js';
|
||||||
import EventTarget from '../../../../src/ol/events/EventTarget.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 MouseSource from '../../../../src/ol/pointer/MouseSource.js';
|
||||||
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
|
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
|
||||||
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.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() {
|
describe('ol.pointer.PointerEventHandler', function() {
|
||||||
@@ -15,10 +17,31 @@ describe('ol.pointer.PointerEventHandler', function() {
|
|||||||
target = new EventTarget();
|
target = new EventTarget();
|
||||||
|
|
||||||
// make sure that a mouse event source is used
|
// make sure that a mouse event source is used
|
||||||
_ol_has_.POINTER = false;
|
const POINTER = false;
|
||||||
_ol_has_.MSPOINTER = 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);
|
handler = new PointerEventHandler(target);
|
||||||
|
PointerEventHandler.prototype.registerSources = originalRegisterSources;
|
||||||
|
|
||||||
eventSpy = sinon.spy();
|
eventSpy = sinon.spy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import {listen} from '../../../../src/ol/events.js';
|
import {listen} from '../../../../src/ol/events.js';
|
||||||
import Event from '../../../../src/ol/events/Event.js';
|
import Event from '../../../../src/ol/events/Event.js';
|
||||||
import EventTarget from '../../../../src/ol/events/EventTarget.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 {assign} from '../../../../src/ol/obj.js';
|
||||||
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.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() {
|
describe('ol.pointer.TouchSource', function() {
|
||||||
let handler;
|
let handler;
|
||||||
@@ -14,11 +17,31 @@ describe('ol.pointer.TouchSource', function() {
|
|||||||
target = new EventTarget();
|
target = new EventTarget();
|
||||||
|
|
||||||
// make sure that a mouse and touch event source is used
|
// make sure that a mouse and touch event source is used
|
||||||
_ol_has_.POINTER = false;
|
const POINTER = false;
|
||||||
_ol_has_.MSPOINTER = false;
|
const MSPOINTER = false;
|
||||||
_ol_has_.TOUCH = true;
|
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);
|
handler = new PointerEventHandler(target);
|
||||||
|
PointerEventHandler.prototype.registerSources = originalRegisterSources;
|
||||||
|
|
||||||
eventSpy = sinon.spy();
|
eventSpy = sinon.spy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {equals} from '../../../src/ol/array.js';
|
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 {toContext} from '../../../src/ol/render.js';
|
||||||
import CanvasImmediateRenderer from '../../../src/ol/render/canvas/Immediate.js';
|
import CanvasImmediateRenderer from '../../../src/ol/render/canvas/Immediate.js';
|
||||||
import _ol_transform_ from '../../../src/ol/transform.js';
|
import _ol_transform_ from '../../../src/ol/transform.js';
|
||||||
@@ -13,7 +13,7 @@ describe('ol.render', function() {
|
|||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const render = toContext(canvas.getContext('2d'));
|
const render = toContext(canvas.getContext('2d'));
|
||||||
expect(render).to.be.a(CanvasImmediateRenderer);
|
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() {
|
it('sets size and pixel ratio from options', function() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {equals} from '../src/ol/array.js';
|
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
|
// avoid importing anything that results in an instanceof check
|
||||||
// since these extensions are global, instanceof checks fail with modules
|
// 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) {
|
global.assertWebGL = function(map) {
|
||||||
if (!_ol_has_.WEBGL) {
|
if (!WEBGL) {
|
||||||
expect().fail('No WebGL support!');
|
expect().fail('No WebGL support!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user