mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 14:45:12 +02:00
Memoize and avoid extra calls to utilDetect()
This commit is contained in:
@@ -18,6 +18,7 @@ var apibase = 'https://a.mapillary.com/v2/',
|
||||
maxPages = 10,
|
||||
tileZoom = 14,
|
||||
dispatch = d3.dispatch('loadedImages', 'loadedSigns'),
|
||||
detected = utilDetect(),
|
||||
mapillaryCache,
|
||||
mapillaryClicks,
|
||||
mapillaryImage,
|
||||
@@ -298,7 +299,6 @@ export default {
|
||||
|
||||
|
||||
signsSupported: function() {
|
||||
var detected = utilDetect();
|
||||
return (!(detected.ie || detected.browser.toLowerCase() === 'safari'));
|
||||
},
|
||||
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import toGeoJSON from 'togeojson';
|
||||
|
||||
export function svgGpx(projection, context, dispatch) {
|
||||
var showLabels = true,
|
||||
detected = utilDetect(),
|
||||
layer;
|
||||
|
||||
|
||||
@@ -27,7 +28,7 @@ export function svgGpx(projection, context, dispatch) {
|
||||
.on('drop.localgpx', function() {
|
||||
d3.event.stopPropagation();
|
||||
d3.event.preventDefault();
|
||||
if (!utilDetect().filedrop) return;
|
||||
if (!detected.filedrop) return;
|
||||
drawGpx.files(d3.event.dataTransfer.files);
|
||||
})
|
||||
.on('dragenter.localgpx', over)
|
||||
|
||||
@@ -340,7 +340,7 @@ export function svgLabels(projection, context) {
|
||||
|
||||
var coord = projection(entity.loc),
|
||||
margin = 2,
|
||||
textDirection = utilDetect().textDirection,
|
||||
textDirection = detected.textDirection,
|
||||
offset = pointOffsets[textDirection],
|
||||
p = {
|
||||
height: height,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { utilDetect } from '../util/detect';
|
||||
|
||||
|
||||
export function svgLines(projection) {
|
||||
var detected = utilDetect();
|
||||
|
||||
var highway_stack = {
|
||||
motorway: 0,
|
||||
@@ -135,7 +136,7 @@ export function svgLines(projection) {
|
||||
.merge(oneways)
|
||||
.attr('d', function(d) { return d.d; });
|
||||
|
||||
if (utilDetect().ie) {
|
||||
if (detected.ie) {
|
||||
oneways.each(function() { this.parentNode.insertBefore(this, this); });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ import { tooltip } from '../util/tooltip';
|
||||
|
||||
export function uiBackground(context) {
|
||||
var key = 'B',
|
||||
detected = utilDetect(),
|
||||
opacities = [1, 0.75, 0.5, 0.25],
|
||||
directions = [
|
||||
['right', [0.5, 0]],
|
||||
@@ -45,7 +46,7 @@ export function uiBackground(context) {
|
||||
.style('opacity', d)
|
||||
.attr('data-opacity', d);
|
||||
|
||||
if (!utilDetect().opera) {
|
||||
if (!detected.opera) {
|
||||
utilSetTransform(bg, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { currentLocale, setTextDirection } from './locale';
|
||||
import { utilStringQs } from './index';
|
||||
|
||||
var detected;
|
||||
|
||||
export function utilDetect() {
|
||||
var detected = {};
|
||||
if (detected) return detected;
|
||||
detected = {};
|
||||
|
||||
var ua = navigator.userAgent,
|
||||
m = null;
|
||||
|
||||
Reference in New Issue
Block a user