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

Commit

Permalink
fix(select): reposition select on resize events
Browse files Browse the repository at this point in the history
closes #1665
  • Loading branch information
rschmukler committed Apr 5, 2015
1 parent 1a81f0c commit 0fe35cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/backdrop/backdrop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ md-backdrop {
right: 0;

&.md-click-catcher {
top: 0px;
position: fixed;
}

Expand Down
14 changes: 13 additions & 1 deletion src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function SelectProvider($$interimElementProvider) {
});

/* @ngInject */
function selectDefaultOptions($mdSelect, $mdConstant, $$rAF, $mdUtil, $mdTheming, $timeout) {
function selectDefaultOptions($mdSelect, $mdConstant, $$rAF, $mdUtil, $mdTheming, $timeout, $window) {
return {
parent: 'body',
onShow: onShow,
Expand All @@ -698,6 +698,14 @@ function SelectProvider($$interimElementProvider) {
backdrop: opts.hasBackdrop && angular.element('<md-backdrop class="md-select-backdrop md-click-catcher">')
});

opts.resizeFn = function() {
animateSelect(scope, element, opts);
};

angular.element($window).on('resize', opts.resizeFn);
angular.element($window).on('orientationchange', opts.resizeFn);


configureAria();

element.removeClass('md-leave');
Expand Down Expand Up @@ -853,6 +861,10 @@ function SelectProvider($$interimElementProvider) {
delete opts.disableTarget;
}

angular.element($window).off('resize', opts.resizefn);
angular.element($window).off('orientationchange', opts.resizefn);
opts.resizeFn = undefined;

var mdSelect = opts.selectEl.controller('mdSelect');
if (mdSelect) {
mdSelect.setLabelText(opts.selectEl.controller('mdSelectMenu').selectedLabels());
Expand Down

0 comments on commit 0fe35cc

Please sign in to comment.