Merge pull request #9626 from fredj/rm_from_has
Remove TOUCH, POINTER and MSPOINTER from ol/has
This commit is contained in:
@@ -4,9 +4,19 @@
|
|||||||
|
|
||||||
#### Backwards incompatible changes
|
#### Backwards incompatible changes
|
||||||
|
|
||||||
|
#### Removal of `TOUCH` constant from `ol/has`
|
||||||
|
|
||||||
|
If you were previously using this constant, you can check if `'ontouchstart'` is defined in `window` instead.
|
||||||
|
|
||||||
|
```js
|
||||||
|
if ('ontouchstart' in window) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### Removal of `GEOLOCATION` constant from `ol/has`
|
#### Removal of `GEOLOCATION` constant from `ol/has`
|
||||||
|
|
||||||
If you were previously using this constant, you can check if `'geolocation'` is define in `navigator` instead.
|
If you were previously using this constant, you can check if `'geolocation'` is defined in `navigator` instead.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
if ('geolocation' in navigator) {
|
if ('geolocation' in navigator) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {listen, unlistenByKey, unlisten} from './events.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 {DEVICE_PIXEL_RATIO, TOUCH} from './has.js';
|
import {DEVICE_PIXEL_RATIO} from './has.js';
|
||||||
import LayerGroup from './layer/Group.js';
|
import LayerGroup from './layer/Group.js';
|
||||||
import {hasArea} from './size.js';
|
import {hasArea} from './size.js';
|
||||||
import {DROP} from './structs/PriorityQueue.js';
|
import {DROP} from './structs/PriorityQueue.js';
|
||||||
@@ -230,7 +230,7 @@ class PluggableMap extends BaseObject {
|
|||||||
* @type {!HTMLElement}
|
* @type {!HTMLElement}
|
||||||
*/
|
*/
|
||||||
this.viewport_ = document.createElement('div');
|
this.viewport_ = document.createElement('div');
|
||||||
this.viewport_.className = 'ol-viewport' + (TOUCH ? ' ol-touch' : '');
|
this.viewport_.className = 'ol-viewport' + ('ontouchstart' in window ? ' 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%';
|
||||||
|
|||||||
@@ -39,30 +39,4 @@ export const MAC = ua.indexOf('macintosh') !== -1;
|
|||||||
*/
|
*/
|
||||||
export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True if browser supports touch events.
|
|
||||||
* @const
|
|
||||||
* @type {boolean}
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
export const TOUCH = 'ontouchstart' in window;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True if browser supports pointer events.
|
|
||||||
* @const
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
export const POINTER = 'PointerEvent' in window;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True if browser supports ms pointer events (IE 10).
|
|
||||||
* @const
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
export const MSPOINTER = !!(navigator.msPointerEnabled);
|
|
||||||
|
|
||||||
|
|
||||||
export {HAS as WEBGL} from './webgl.js';
|
export {HAS as WEBGL} from './webgl.js';
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
import {listen, unlisten} from '../events.js';
|
import {listen, unlisten} from '../events.js';
|
||||||
import EventTarget from '../events/Target.js';
|
import EventTarget from '../events/Target.js';
|
||||||
import {POINTER, MSPOINTER, TOUCH} from '../has.js';
|
|
||||||
import PointerEventType from './EventType.js';
|
import PointerEventType from './EventType.js';
|
||||||
import MouseSource, {prepareEvent as prepareMouseEvent} from './MouseSource.js';
|
import MouseSource, {prepareEvent as prepareMouseEvent} from './MouseSource.js';
|
||||||
import MsSource from './MsSource.js';
|
import MsSource from './MsSource.js';
|
||||||
@@ -124,15 +123,15 @@ class PointerEventHandler extends EventTarget {
|
|||||||
* that generate pointer events.
|
* that generate pointer events.
|
||||||
*/
|
*/
|
||||||
registerSources() {
|
registerSources() {
|
||||||
if (POINTER) {
|
if ('PointerEvent' in window) {
|
||||||
this.registerSource('native', new NativeSource(this));
|
this.registerSource('native', new NativeSource(this));
|
||||||
} else if (MSPOINTER) {
|
} else if (window.navigator.msPointerEnabled) {
|
||||||
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 (TOUCH) {
|
if ('ontouchstart' in window) {
|
||||||
this.registerSource('touch', new TouchSource(this, mouseSource));
|
this.registerSource('touch', new TouchSource(this, mouseSource));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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, Point} from '../../../src/ol/geom.js';
|
import {LineString, Point} from '../../../src/ol/geom.js';
|
||||||
import {TOUCH} from '../../../src/ol/has.js';
|
|
||||||
import {focus} from '../../../src/ol/events/condition.js';
|
import {focus} from '../../../src/ol/events/condition.js';
|
||||||
import {defaults as defaultInteractions} from '../../../src/ol/interaction.js';
|
import {defaults as defaultInteractions} from '../../../src/ol/interaction.js';
|
||||||
import {get as getProjection} from '../../../src/ol/proj.js';
|
import {get as getProjection} from '../../../src/ol/proj.js';
|
||||||
@@ -45,7 +44,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' + (TOUCH ? ' ol-touch' : '');
|
const className = 'ol-viewport' + ('ontouchstart' in window ? ' ol-touch' : '');
|
||||||
expect(viewport.className).to.be(className);
|
expect(viewport.className).to.be(className);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user