Remove legacy IE support
This commit is contained in:
+2
-112
@@ -29,15 +29,6 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {boolean}
|
||||
*/
|
||||
ol.dom.BrowserFeature = {
|
||||
USE_MS_MATRIX_TRANSFORM: ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE,
|
||||
USE_MS_ALPHA_FILTER: ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Detect 2d transform.
|
||||
* Adapted from http://stackoverflow.com/q/5661671/130442
|
||||
@@ -137,87 +128,18 @@ ol.dom.setTransform = function(element, value) {
|
||||
style.transform = value;
|
||||
|
||||
// IE 9+ seems to assume transform-origin: 100% 100%; for some unknown reason
|
||||
if (goog.userAgent.IE && !ol.IS_LEGACY_IE) {
|
||||
if (goog.userAgent.IE && goog.userAgent.isVersionOrHigher('9.0')) {
|
||||
element.style.transformOrigin = '0 0';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the opacity of an element, in an IE-compatible way
|
||||
* @param {!Element} element Element
|
||||
* @param {number} value Opacity, [0..1]
|
||||
*/
|
||||
ol.dom.setOpacity = function(element, value) {
|
||||
if (ol.dom.BrowserFeature.USE_MS_ALPHA_FILTER) {
|
||||
/** @type {string} */
|
||||
var filter = element.currentStyle.filter;
|
||||
|
||||
/** @type {RegExp} */
|
||||
var regex;
|
||||
|
||||
/** @type {string} */
|
||||
var alpha;
|
||||
|
||||
if (goog.userAgent.VERSION == '8.0') {
|
||||
regex = /progid:DXImageTransform\.Microsoft\.Alpha\(.*?\)/i;
|
||||
alpha = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' +
|
||||
(value * 100) + ')';
|
||||
} else {
|
||||
regex = /alpha\(.*?\)/i;
|
||||
alpha = 'alpha(opacity=' + (value * 100) + ')';
|
||||
}
|
||||
|
||||
var newFilter = filter.replace(regex, alpha);
|
||||
if (newFilter === filter) {
|
||||
// no replace was made? just append the new alpha filter instead
|
||||
newFilter += ' ' + alpha;
|
||||
}
|
||||
|
||||
element.style.filter = newFilter;
|
||||
|
||||
// Fix to apply filter to absolutely-positioned children element
|
||||
if (element.currentStyle.zIndex === 'auto') {
|
||||
element.style.zIndex = 0;
|
||||
}
|
||||
} else {
|
||||
element.style.opacity = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the IE matrix transform without replacing other filters
|
||||
* @private
|
||||
* @param {!Element} element Element
|
||||
* @param {string} value The new progid string
|
||||
*/
|
||||
ol.dom.setIEMatrix_ = function(element, value) {
|
||||
var filter = element.currentStyle.filter;
|
||||
var newFilter =
|
||||
filter.replace(/progid:DXImageTransform.Microsoft.Matrix\(.*?\)/i, value);
|
||||
|
||||
if (newFilter === filter) {
|
||||
newFilter = ' ' + value;
|
||||
}
|
||||
|
||||
element.style.filter = newFilter;
|
||||
|
||||
// Fix to apply filter to absolutely-positioned children element
|
||||
if (element.currentStyle.zIndex === 'auto') {
|
||||
element.style.zIndex = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!Element} element Element.
|
||||
* @param {goog.vec.Mat4.Number} transform Matrix.
|
||||
* @param {number=} opt_precision Precision.
|
||||
* @param {Element=} opt_translationElement Required for IE7-8
|
||||
*/
|
||||
ol.dom.transformElement2D =
|
||||
function(element, transform, opt_precision, opt_translationElement) {
|
||||
ol.dom.transformElement2D = function(element, transform, opt_precision) {
|
||||
// using matrix() causes gaps in Chrome and Firefox on Mac OS X, so prefer
|
||||
// matrix3d()
|
||||
var i;
|
||||
@@ -257,38 +179,6 @@ ol.dom.transformElement2D =
|
||||
value2D = transform2D.join(',');
|
||||
}
|
||||
ol.dom.setTransform(element, 'matrix(' + value2D + ')');
|
||||
} else if (ol.dom.BrowserFeature.USE_MS_MATRIX_TRANSFORM) {
|
||||
var m11 = goog.vec.Mat4.getElement(transform, 0, 0),
|
||||
m12 = goog.vec.Mat4.getElement(transform, 0, 1),
|
||||
m21 = goog.vec.Mat4.getElement(transform, 1, 0),
|
||||
m22 = goog.vec.Mat4.getElement(transform, 1, 1),
|
||||
dx = goog.vec.Mat4.getElement(transform, 0, 3),
|
||||
dy = goog.vec.Mat4.getElement(transform, 1, 3);
|
||||
|
||||
// See: http://msdn.microsoft.com/en-us/library/ms533014(v=vs.85).aspx
|
||||
// and: http://extremelysatisfactorytotalitarianism.com/blog/?p=1002
|
||||
// @TODO: fix terrible IE bbox rotation issue.
|
||||
var s = 'progid:DXImageTransform.Microsoft.Matrix(';
|
||||
s += 'sizingMethod="auto expand"';
|
||||
s += ',M11=' + m11.toFixed(opt_precision || 20);
|
||||
s += ',M12=' + m12.toFixed(opt_precision || 20);
|
||||
s += ',M21=' + m21.toFixed(opt_precision || 20);
|
||||
s += ',M22=' + m22.toFixed(opt_precision || 20);
|
||||
s += ')';
|
||||
ol.dom.setIEMatrix_(element, s);
|
||||
|
||||
// scale = m11 = m22 = target resolution [m/px] / current res [m/px]
|
||||
// dx = (viewport width [px] / 2) * scale
|
||||
// + (layer.x [m] - view.x [m]) / target resolution [m / px]
|
||||
// except that we're positioning the child element relative to the
|
||||
// viewport, not the map.
|
||||
// dividing by the scale factor isn't the exact correction, but it's
|
||||
// close enough that you can barely tell unless you're looking for it
|
||||
dx /= m11;
|
||||
dy /= m22;
|
||||
|
||||
opt_translationElement.style.left = Math.round(dx) + 'px';
|
||||
opt_translationElement.style.top = Math.round(dy) + 'px';
|
||||
} else {
|
||||
element.style.left =
|
||||
Math.round(goog.vec.Mat4.getElement(transform, 0, 3)) + 'px';
|
||||
|
||||
Reference in New Issue
Block a user