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

Commit ffe9349

Browse files
Noglenmmalerba
authored andcommitted
fix(panel): append panel animation transforms after existing transforms (#11681)
append the transform for panel animations after any existing transforms. Previously, the animation transform was appened first, resulting in the destination location being incorrect.
1 parent 197d197 commit ffe9349

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/components/panel/panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,7 +3371,7 @@ MdPanelAnimation.prototype.animateOpen = function(panelEl) {
33713371

33723372
var openScale = animator.calculateZoomToOrigin(
33733373
panelEl, this._openFrom) || '';
3374-
openFrom = animator.toTransformCss(openScale + ' ' + panelTransform);
3374+
openFrom = animator.toTransformCss(panelTransform + ' ' + openScale);
33753375
break;
33763376

33773377
case MdPanelAnimation.animation.FADE:
@@ -3436,7 +3436,7 @@ MdPanelAnimation.prototype.animateClose = function(panelEl) {
34363436

34373437
var closeScale = animator.calculateZoomToOrigin(
34383438
panelEl, this._closeTo) || '';
3439-
closeTo = animator.toTransformCss(closeScale + ' ' + panelTransform);
3439+
closeTo = animator.toTransformCss(panelTransform + ' ' + closeScale);
34403440
break;
34413441

34423442
case MdPanelAnimation.animation.FADE:

src/components/panel/panel.spec.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,49 @@ describe('$mdPanel', function() {
29572957
expect(backdropAnimation._closeDuration).toBe(mdPanelAnimation._closeDuration);
29582958
});
29592959

2960+
describe('should add scale after the existing transform when', function () {
2961+
var animator;
2962+
var panelEl;
2963+
2964+
beforeEach(function () {
2965+
animator = mdPanelAnimation._$mdUtil.dom.animator;
2966+
2967+
var panelDiv = document.createElement('div');
2968+
panelDiv.id = 'mockPanel'
2969+
panelDiv.style.transform = 'translateX(-50%) translateY(-50%)'
2970+
attachToBody(panelDiv);
2971+
panelEl = angular.element(panelDiv);
2972+
2973+
spyOn(animator, 'translate3d');
2974+
2975+
spyOn(animator, 'calculateZoomToOrigin')
2976+
.and.returnValue('translate3d(0, 0, 0) scale(0.5, 0.5)');
2977+
2978+
});
2979+
2980+
it('opening with the SCALE animation', function () {
2981+
var animation = mdPanelAnimation.openFrom('button')
2982+
.withAnimation('md-panel-animate-scale')
2983+
2984+
animation.animateOpen(panelEl);
2985+
2986+
expect(animator.translate3d.calls.mostRecent().args[1].transform)
2987+
.toMatch(/^translateX.*scale\(0\.5, 0\.5\)$/g);
2988+
2989+
});
2990+
2991+
it('closing with the SCALE animation', function () {
2992+
var animation = mdPanelAnimation.openFrom('button')
2993+
.withAnimation('md-panel-animate-scale')
2994+
2995+
animation.animateClose(panelEl);
2996+
2997+
expect(animator.translate3d.calls.mostRecent().args[2].transform)
2998+
.toMatch(/^translateX.*scale\(0\.5, 0\.5\)$/g);
2999+
3000+
});
3001+
});
3002+
29603003
describe('should determine openFrom when', function() {
29613004
it('provided a selector', function() {
29623005
var animation = mdPanelAnimation.openFrom('button');

0 commit comments

Comments
 (0)