Package Exports
- popper-max-size-modifier
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (popper-max-size-modifier) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
popper-max-size-modifier
A Popper.js modifier to change the size of your popper to fit it within the available viewport space.
Usage
import {createPopper} from '@popperjs/core';
import maxSize from 'popper-max-size-modifier';
// Create your own apply modifier that mutates the popper element's styles:
const applyMaxSize = {
name: 'applyMaxSize',
enabled: true,
phase: 'write',
requires: ['maxSize'],
fn({state}) {
// The `maxSize` modifier provides this data
const {width, height} = state.modifiersData.maxSize;
state.elements.popper.style.maxWidth = `${width}px`;
state.elements.popper.style.maxHeight = `${height}px`;
}
};
createPopper(reference, popper, {
modifiers: [maxSize, applyMaxSize]
});
Sometimes you may want the flip
modifier to take precedence in cases where the maxSize
modifier will make the popper too small (e.g. a minimum acceptable size):
// Minimum acceptable size is 100px
state.elements.popper.style.maxWidth = `${Math.max(100, width)}px`;
state.elements.popper.style.maxHeight = `${Math.max(100, height)}px`;