0.1.1 • Published 5 years ago

tux-autoscale v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

TUX Autoscale component

Autoscale element to fill a container.

Usage

HTML Markup:

<div class="with-Autoscale">
    <img data-autoscale src="//lorempixel.com/1600/1200/cats/">
</div>

The only requirement for styling is that the parent element has the class with-Autoscale or the following styles.

.with-Autoscale {
  overflow: hidden;
  position: relative;
}

Options

Options can be passed via JavaScript.

NameTypeDefaultDescription
autoscalestringcoverTwo modes: cover and contain. This option can be past to the initializing data attribute: data-autoscale="contain".
rationumberundefinedSet a predefined ratio.
heightnumberundefinedSet a fixed height.
widthnumberundefinedSet a fixed width.

You have to supply both width and height if you want to set an initial size. This makes images render in correct size while they are loading.

License

MIT © Aranja

0.1.1

5 years ago

0.1.0

9 years ago

0.0.1

9 years ago