0.2.7 • Published 1 month ago

@zsjs/resize-fit v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

title: resize-fit group: controllers

subGroup: general

Instruction

This ResizeFit was designed to fit the upper container of a div, similar to the fit attribute of an image element.

Demos

fill

contain

fitHeight

fitWidth

fitWidthExtendHeight

install

npm install @zsjs/resize-fit;

Example

import { ResizeFit } from "@zsjs/resize-fit";

<div id="father" style="width: 400px;height: 300px;border: 1px solid green;">
  <div id="child" style="width: 100px;height: 200px;background-color: red;">
    <span style="font-size: 58px;">ResizeFit</span>
  </div>
</div>
const resizeFit = new ResizeFit();
resizeFit.init({
  container: document.getElementById("father"),
  target: document.getElementById("child"),
  mode: "contain", // fill | contain | fitHeight | fitWidth | fitWidthExtendHeight |
})

// before unmount
resizeFit.dispose();

Methods

dispose

Remove the listener of ResizeObserver.

example

resizeFit.dispose();

0.2.7

1 month ago

0.2.6

1 month ago

0.2.5

1 month ago

0.2.3

1 month ago

0.2.4

1 month ago

0.2.2

3 months ago

0.2.1

3 months ago

0.2.0

4 months ago

0.1.0

4 months ago

0.1.1

4 months ago

0.0.1

4 months ago