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

Commit 0168e86

Browse files
committed
fix(panel): updates to positioning
1 parent bd8b678 commit 0168e86

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

src/components/panel/demoBasicUsage/panel.tmpl.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ <h2>Surprise!</h2>
1616
</div>
1717

1818
<div layout="row" class="demo-dialog-button">
19-
<md-button flex class="md-primary">
20-
Nothing
21-
</md-button>
2219
<md-button md-autofocus flex class="md-primary" ng-click="ctrl.closeDialog()">
2320
Close
2421
</md-button>

src/components/panel/demoPanelAnimations/panel.tmpl.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ <h2>Surprise!</h2>
1616
</div>
1717

1818
<div layout="row" class="demo-dialog-button">
19-
<md-button flex class="md-primary">
20-
Nothing
21-
</md-button>
2219
<md-button md-autofocus flex class="md-primary" ng-click="ctrl.closeDialog()">
2320
Close
2421
</md-button>

src/components/panel/panel.js

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,11 @@ MdPanelRef.prototype._addStyles = function() {
11041104
// correctly. This is necessary so that the panel will have a defined height
11051105
// and width.
11061106
self._$rootScope['$$postDigest'](function() {
1107-
self._panelEl.css('top', positionConfig.getTop(self._panelEl));
1108-
self._panelEl.css('bottom', positionConfig.getBottom(self._panelEl));
1109-
self._panelEl.css('left', positionConfig.getLeft(self._panelEl));
1110-
self._panelEl.css('right', positionConfig.getRight(self._panelEl));
1107+
positionConfig._calculatePanelPosition(self._panelEl);
1108+
self._panelEl.css('top', positionConfig.getTop());
1109+
self._panelEl.css('bottom', positionConfig.getBottom());
1110+
self._panelEl.css('left', positionConfig.getLeft());
1111+
self._panelEl.css('right', positionConfig.getRight());
11111112

11121113
// Use the vendor prefixed version of transform.
11131114
var prefixedTransform = self._$mdConstant.CSS.TRANSFORM;
@@ -1412,9 +1413,6 @@ function MdPanelPosition() {
14121413
/** @private {!DOMRect} */
14131414
this._relativeToRect;
14141415

1415-
/** @private {boolean} */
1416-
this._panelPositionCalculated = false;
1417-
14181416
/** @private {string} */
14191417
this._top = '';
14201418

@@ -1677,44 +1675,36 @@ MdPanelPosition.prototype.withOffsetY = function(offsetY) {
16771675

16781676
/**
16791677
* Gets the value of `top` for the panel.
1680-
* @param {!angular.JQLite} panelEl
16811678
* @returns {string}
16821679
*/
1683-
MdPanelPosition.prototype.getTop = function(panelEl) {
1684-
this._calculatePanelPosition(panelEl);
1680+
MdPanelPosition.prototype.getTop = function() {
16851681
return this._top;
16861682
};
16871683

16881684

16891685
/**
16901686
* Gets the value of `bottom` for the panel.
1691-
* @param {!angular.JQLite} panelEl
16921687
* @returns {string}
16931688
*/
1694-
MdPanelPosition.prototype.getBottom = function(panelEl) {
1695-
this._calculatePanelPosition(panelEl);
1689+
MdPanelPosition.prototype.getBottom = function() {
16961690
return this._bottom;
16971691
};
16981692

16991693

17001694
/**
17011695
* Gets the value of `left` for the panel.
1702-
* @param {!angular.JQLite} panelEl
17031696
* @returns {string}
17041697
*/
1705-
MdPanelPosition.prototype.getLeft = function(panelEl) {
1706-
this._calculatePanelPosition(panelEl);
1698+
MdPanelPosition.prototype.getLeft = function() {
17071699
return this._left;
17081700
};
17091701

17101702

17111703
/**
17121704
* Gets the value of `right` for the panel.
1713-
* @param {!angular.JQLite} panelEl
17141705
* @returns {string}
17151706
*/
1716-
MdPanelPosition.prototype.getRight = function(panelEl) {
1717-
this._calculatePanelPosition(panelEl);
1707+
MdPanelPosition.prototype.getRight = function() {
17181708
return this._right;
17191709
};
17201710

@@ -1735,7 +1725,7 @@ MdPanelPosition.prototype.getTransform = function() {
17351725

17361726
/**
17371727
* Gets the first x/y position that can fit on-screen.
1738-
* @returns {string}
1728+
* @returns {{x: string, y: string}}
17391729
*/
17401730
MdPanelPosition.prototype.getActualPosition = function() {
17411731
// TODO(gmoothart): intelligently pick the first on-screen position.
@@ -1766,16 +1756,13 @@ MdPanelPosition.prototype._reduceTranslateValues =
17661756
*/
17671757
MdPanelPosition.prototype._calculatePanelPosition = function(panelEl) {
17681758
// Only calculate the position if necessary.
1769-
if (this._absolute || this._panelPositionCalculated) {
1759+
if (this._absolute) {
17701760
return;
17711761
}
17721762

17731763
// TODO(ErinCoughlan): Update position on scroll.
17741764
// TODO(ErinCoughlan): Position panel intelligently to keep it on screen.
17751765

1776-
// Indicate that the position is calculated so it can be skipped next time.
1777-
this._panelPositionCalculated = true;
1778-
17791766
var panelBounds = panelEl[0].getBoundingClientRect();
17801767
var panelWidth = panelBounds.width;
17811768
var panelHeight = panelBounds.height;

0 commit comments

Comments
 (0)