more clever prefix detection. (use unprefixed property when available.)

This commit is contained in:
tyr
2012-12-06 10:32:02 +01:00
parent 25b6290f4d
commit e4ceca76ec
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ 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(['webkit', 'ms', 'Moz']) + 'transform',
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'),
+9
View File
@@ -72,6 +72,15 @@ iD.util.prefix = function(browsers) {
return '';
})(browsers);
};
iD.util.prefixProperty = function(property) {
prefixes = ['webkit', 'ms', 'Moz', 'O'];
return (function prefixMatch(p) { // via mbostock
var i = -1, n = p.length, s = document.body.style;
if (property.toLowerCase() in s) return property.toLowerCase();
while (++i < n) if (p[i] + property in s) return '-' + p[i].toLowerCase() + '-' + property.toLowerCase();
return '';
})(prefixes);
};
iD.util.geo = {};