adaptable-text
![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)
Adapt font size to a specified width.
Install
$ npm install --save adaptable-text
Usage
const textToAdapt = new AdaptableText(document.querySelector(".textToAdapt"), {
step: 0.1,
minFontSize: 10,
width: null
});
textToAdapt.init();
const adapt = () => {
textToAdapt.setWidth();
textToAdapt.adapt();
};
window.addEventListener("resize", adapt);
requestIdleCallback(() => {
adapt();
});
Key | Description |
---|
step | The step used by the generator to calculate the width of the element |
minFontSize | A minimum font size for the element (max would be the size defined in a stylesheet retrieved by window.getComputedStyle(this.element) ) |
width | A maximum widht for the container. |
Scripts
Dev
npm run dev
Test
npm run test
Build
npm run build
License
MIT © Damien Seguin