1.0.0 • Published 6 years ago

flowtype-es v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

ES6 FlowType.js

Build Status

FlowType ES is a rewrite of the awesome FlowType.JS in ES6. It doesn't require jQuery and triggers recalculation on requestAnimationFrame.

Install

npm install flowtype-es

API

import createFlowtype from "flowtype-es";

const flowtype = createFlowtype(element, options)

Creates and attaches event listeners for automatic recalculation of the font size upon resizing the element.

  • element is a reference to the dom element for which the font size should be calculated automatically.
  • options lets you customize the calculation of the font size.

Returns an object with update() and destroy().

flowtype.update()

Triggers a recalculation of the font size.

flowtype.destroy()

Removes all event listeners and stops the automatic recalculation of the font size upon resizing the element.

Options

OptionDescriptionDtypeDefault
maximumMax width of the element until the font size is controlledint1200
minimumMin width of the element until the font size is controlledint500
maxFontMax font size ever usedint40
minFontMin font size ever usedint12
fontRatioFont ratio for determining the font size based on the elements's widthint30

Example

import createFlowtype from "flowtype-es";

const flowtype = createFlowtype(document.body, {
  maximum: 1200,
  minimum: 500,
  maxFont: 40,
  minFont: 12,
  fontRatio: 30
});