Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 7706162

Browse files
crisbetokara
authored andcommitted
fix(panel): use prefixed transform property (#9721)
Fixes a JS error in the panel, if the user's browser uses the prefixed `transform` property.
1 parent e0463c0 commit 7706162

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/panel/panel.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,9 @@ function MdPanelPosition($injector) {
20872087
/** @private {boolean} */
20882088
this._isRTL = $injector.get('$mdUtil').bidi() === 'rtl';
20892089

2090+
/** @private @const {!angular.$mdConstant} */
2091+
this._$mdConstant = $injector.get('$mdConstant');
2092+
20902093
/** @private {boolean} */
20912094
this._absolute = false;
20922095

@@ -2475,7 +2478,8 @@ MdPanelPosition.prototype._isOnscreen = function(panelEl) {
24752478
var top = parseInt(this.getTop());
24762479

24772480
if (this._translateX.length || this._translateY.length) {
2478-
var offsets = getComputedTranslations(panelEl);
2481+
var prefixedTransform = this._$mdConstant.CSS.TRANSFORM;
2482+
var offsets = getComputedTranslations(panelEl, prefixedTransform);
24792483
left += offsets.x;
24802484
top += offsets.y;
24812485
}
@@ -2990,13 +2994,14 @@ function getElement(el) {
29902994
/**
29912995
* Gets the computed values for an element's translateX and translateY in px.
29922996
* @param {!angular.JQLite|!Element} el
2997+
* @param {string} property
29932998
* @return {{x: number, y: number}}
29942999
*/
2995-
function getComputedTranslations(el) {
3000+
function getComputedTranslations(el, property) {
29963001
// The transform being returned by `getComputedStyle` is in the format:
29973002
// `matrix(a, b, c, d, translateX, translateY)` if defined and `none`
29983003
// if the element doesn't have a transform.
2999-
var transform = getComputedStyle(el[0] || el).transform;
3004+
var transform = getComputedStyle(el[0] || el)[property];
30003005
var openIndex = transform.indexOf('(');
30013006
var closeIndex = transform.lastIndexOf(')');
30023007
var output = { x: 0, y: 0 };

0 commit comments

Comments
 (0)