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

Commit

Permalink
fix(select): make constrained select fit to top/left first
Browse files Browse the repository at this point in the history
closes #1899
  • Loading branch information
rschmukler committed Apr 5, 2015
1 parent 4d71436 commit f6f2187
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ function SelectProvider($$interimElementProvider) {

// Keep left and top within the window
var containerRect = containerNode.getBoundingClientRect();
debugger;
containerNode.style.left = clamp(bounds.left, left, bounds.right - containerRect.width) + 'px';
containerNode.style.top = clamp(bounds.top, top, bounds.bottom - containerRect.height) + 'px';
selectNode.style[$mdConstant.CSS.TRANSFORM_ORIGIN] = transformOrigin;
Expand All @@ -975,7 +976,7 @@ function SelectProvider($$interimElementProvider) {
}

function clamp(min, n, max) {
return Math.min(max, Math.max(n, min));
return Math.max(min, Math.min(n, max));
}

function getOffsetRect(node) {
Expand Down

0 comments on commit f6f2187

Please sign in to comment.