diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index fcad51151..b3e2a54c1 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -53,8 +53,19 @@ iD.Map = function() { class_fill = iD.Style.styleClasses('stroke'), class_area = iD.Style.styleClasses('area'), class_casing = iD.Style.styleClasses('casing'), - transformProp = iD.util.prefix() + 'transform', - support3d = iD.util.prefix() === 'O', + transformProp = iD.util.prefixProperty('Transform'), + support3d = (function() { + // test for translate3d support. Based on https://gist.github.com/3794226 by lorenzopolidori and webinista + var el = document.createElement('div'), + has3d = false; + document.body.insertBefore(el,null); + if (el.style[transformProp] !== undefined) { + el.style[transformProp] = 'translate3d(1px,1px,1px)'; + has3d = window.getComputedStyle(el).getPropertyValue(transformProp); + } + document.body.removeChild(el); + return (has3d && has3d.length>0 && has3d!=="none"); + })(), supersurface, surface, defs, tilegroup, r, g, alength; function map() { diff --git a/js/id/util.js b/js/id/util.js index bcde828ea..7128673f0 100644 --- a/js/id/util.js +++ b/js/id/util.js @@ -64,12 +64,14 @@ iD.util.qsString = function(obj) { }).join('&'); }; -iD.util.prefix = function() { +iD.util.prefixProperty = function(property) { + var prefixes = ['webkit', 'ms', 'Moz', 'O']; return (function prefixMatch(p) { // via mbostock var i = -1, n = p.length, s = document.body.style; - while (++i < n) if (p[i] + 'Transform' in s) return '-' + p[i].toLowerCase() + '-'; - return ''; - })(['webkit', 'ms', 'Moz', 'O']); + if (property.toLowerCase() in s) return property.toLowerCase(); + while (++i < n) if (p[i] + property in s) return '-' + p[i].toLowerCase() + '-' + property.toLowerCase(); + return false; + })(prefixes); }; iD.util.geo = {};