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

Commit

Permalink
fix(autocomplete): fixes menu flicker
Browse files Browse the repository at this point in the history
Animation transitions are temporarily unavailable, pending a fix to ngAnimate that will re-enable them.
  • Loading branch information
Robert Messerle committed Apr 13, 2015
1 parent 07e8201 commit 9b2dc2c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/autocomplete/js/autocompleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

var ITEM_HEIGHT = 41,
MAX_HEIGHT = 5.5 * ITEM_HEIGHT,
MENU_PADDING = 16;
MENU_PADDING = 8;

function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $timeout, $mdTheming, $window) {
function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $timeout, $mdTheming, $window, $rootElement) {

//-- private variables

Expand Down Expand Up @@ -40,7 +40,6 @@
self.focus = focus;
self.clear = clearValue;
self.select = select;
self.fetch = $mdUtil.debounce(fetchResults);
self.getCurrentDisplayValue = getCurrentDisplayValue;
self.registerSelectedItemWatcher = registerSelectedItemWatcher;
self.unregisterSelectedItemWatcher = unregisterSelectedItemWatcher;
Expand Down Expand Up @@ -68,14 +67,13 @@
vrect = elements.snap.getBoundingClientRect(),
root = elements.root.getBoundingClientRect(),
top = vrect.bottom - root.top,
bot = root.height - vrect.top,
bot = root.bottom - vrect.top,
left = hrect.left - root.left,
width = hrect.width,
styles = {
left: left + 'px',
minWidth: width + 'px',
maxWidth: Math.max(hrect.right - root.left, root.right - hrect.left) - MENU_PADDING + 'px',
opacity: 0
maxWidth: Math.max(hrect.right - root.left, root.right - hrect.left) - MENU_PADDING + 'px'
};
if (top > bot && root.height - hrect.bottom - MENU_PADDING < MAX_HEIGHT) {
styles.top = 'auto';
Expand All @@ -84,14 +82,14 @@
} else {
styles.top = top + 'px';
styles.bottom = 'auto';
styles.maxHeight = Math.min(MAX_HEIGHT, root.height - hrect.bottom - MENU_PADDING) + 'px';
styles.maxHeight = Math.min(MAX_HEIGHT, root.bottom - hrect.bottom - MENU_PADDING) + 'px';
}
$timeout(correctHorizontalAlignment, 0, false);
elements.$.ul.css(styles);

This comment has been minimized.

Copy link
@ThomasBurleson

ThomasBurleson Apr 14, 2015

Contributor

LOL - what is this line ?
Do you not mean elements.ul.css(styles); ?

$timeout(correctHorizontalAlignment, 0, false);

function correctHorizontalAlignment () {
var dropdown = elements.ul.getBoundingClientRect(),
styles = { opacity: 1 };
styles = {};
if (dropdown.right > root.right - MENU_PADDING) {
styles.left = (hrect.right - dropdown.width) + 'px';
}
Expand Down

0 comments on commit 9b2dc2c

Please sign in to comment.