From bf857c419ab81462c86f896ca31d726ae5ac6781 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 18 Oct 2016 21:28:20 -0400 Subject: [PATCH] Center label baseline hack for IE11, Edge (closes #3020) --- css/map.css | 5 +++-- modules/svg/labels.js | 3 +++ modules/ui/init.js | 7 +------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/css/map.css b/css/map.css index b39140df4..d26cfd4e5 100644 --- a/css/map.css +++ b/css/map.css @@ -1322,8 +1322,9 @@ text.pointlabel { } /* Opera doesn't support dominant-baseline. See #715 */ -.opera .linelabel-halo .textpath, -.opera .linelabel .textpath { +/* Safari 10 seems to have regressed too */ +.linelabel-halo .textpath, +.linelabel .textpath { baseline-shift: -33%; dominant-baseline: auto; } diff --git a/modules/svg/labels.js b/modules/svg/labels.js index 56ac81b60..969db0fca 100644 --- a/modules/svg/labels.js +++ b/modules/svg/labels.js @@ -15,6 +15,8 @@ import { utilDisplayName, utilEntitySelector } from '../util/index'; export function svgLabels(projection, context) { var path = d3.geoPath().projection(projection), + detected = utilDetect(), + baselineHack = (detected.ie || detected.browser.toLowerCase() === 'edge'), rdrawn = rbush(), rskipped = rbush(), textWidthCache = {}, @@ -119,6 +121,7 @@ export function svgLabels(projection, context) { texts.enter() .append('text') .attr('class', function(d, i) { return classes + ' ' + labels[i].classes + ' ' + d.id; }) + .attr('dy', baselineHack ? '0.35em' : null) .append('textPath') .attr('class', 'textpath'); diff --git a/modules/ui/init.js b/modules/ui/init.js index 3613c01bb..2dab1a569 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -2,12 +2,11 @@ import * as d3 from 'd3'; import { d3keybinding } from '../lib/d3.keybinding.js'; import { t, textDirection } from '../util/locale'; import { tooltip } from '../util/tooltip'; -import { utilDetect } from '../util/detect'; -import { utilSetDimensions } from '../util/dimensions'; import { svgDefs, svgIcon } from '../svg/index'; import { modeBrowse } from '../modes/index'; import { behaviorHash } from '../behavior/index'; +import { utilSetDimensions } from '../util/dimensions'; import { uiAccount } from './account'; import { uiAttribution } from './attribution'; @@ -39,10 +38,6 @@ export function uiInit(context) { function render(container) { var map = context.map(); - if (utilDetect().opera) { - container.classed('opera', true); - } - var hash = behaviorHash(context); hash();