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

fix(panel): append panel animation transforms after existing transforms #11681

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3371,7 +3371,7 @@ MdPanelAnimation.prototype.animateOpen = function(panelEl) {

var openScale = animator.calculateZoomToOrigin(
panelEl, this._openFrom) || '';
openFrom = animator.toTransformCss(openScale + ' ' + panelTransform);
openFrom = animator.toTransformCss(panelTransform + ' ' + openScale);
break;

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

var closeScale = animator.calculateZoomToOrigin(
panelEl, this._closeTo) || '';
closeTo = animator.toTransformCss(closeScale + ' ' + panelTransform);
closeTo = animator.toTransformCss(panelTransform + ' ' + closeScale);
break;

case MdPanelAnimation.animation.FADE:
Expand Down
43 changes: 43 additions & 0 deletions src/components/panel/panel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,49 @@ describe('$mdPanel', function() {
expect(backdropAnimation._closeDuration).toBe(mdPanelAnimation._closeDuration);
});

describe('should add scale after the existing transform when', function () {
var animator;
var panelEl;

beforeEach(function () {
animator = mdPanelAnimation._$mdUtil.dom.animator;

var panelDiv = document.createElement('div');
panelDiv.id = 'mockPanel'
panelDiv.style.transform = 'translateX(-50%) translateY(-50%)'
attachToBody(panelDiv);
panelEl = angular.element(panelDiv);

spyOn(animator, 'translate3d');

spyOn(animator, 'calculateZoomToOrigin')
.and.returnValue('translate3d(0, 0, 0) scale(0.5, 0.5)');

});

it('opening with the SCALE animation', function () {
var animation = mdPanelAnimation.openFrom('button')
.withAnimation('md-panel-animate-scale')

animation.animateOpen(panelEl);

expect(animator.translate3d.calls.mostRecent().args[1].transform)
.toMatch(/^translateX.*scale\(0\.5, 0\.5\)$/g);

});

it('closing with the SCALE animation', function () {
var animation = mdPanelAnimation.openFrom('button')
.withAnimation('md-panel-animate-scale')

animation.animateClose(panelEl);

expect(animator.translate3d.calls.mostRecent().args[2].transform)
.toMatch(/^translateX.*scale\(0\.5, 0\.5\)$/g);

});
});

describe('should determine openFrom when', function() {
it('provided a selector', function() {
var animation = mdPanelAnimation.openFrom('button');
Expand Down