Improve _posFixed to make sure content never gets cut off on very small view ports.
This commit is contained in:
17
position.js
17
position.js
@ -52,6 +52,12 @@ export const Position = function(superClass) {
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure top never goes below 0
|
||||
if (top < 0) {
|
||||
compTop += Math.abs(top);
|
||||
top = 0;
|
||||
}
|
||||
|
||||
if (options.halign === 'left') {
|
||||
left = anchorRect.left;
|
||||
}
|
||||
@ -74,6 +80,17 @@ export const Position = function(superClass) {
|
||||
left = 0;
|
||||
}
|
||||
|
||||
// Constrain height to viewport - calculate available height from final top position
|
||||
const availableHeight = window.innerHeight - top;
|
||||
if (elRect.height > availableHeight) {
|
||||
el.style.maxHeight = availableHeight + 'px';
|
||||
el.style.overflowY = 'auto';
|
||||
} else {
|
||||
// Reset max-height if element fits
|
||||
el.style.maxHeight = '';
|
||||
el.style.overflowY = '';
|
||||
}
|
||||
|
||||
el.style.top = (top - fixTop) + 'px';
|
||||
el.style.left = (left - fixLeft) + 'px';
|
||||
|
||||
|
Reference in New Issue
Block a user