1.0.0 • Published 3 years ago

dom-resizeable v1.0.0

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

dom-resizeable

Make dom resizeable

Snapshot

snapshot;

Usage

yarn add dom-resizeable
npm install dom-resizeable
// use as commonjs
const Resize = require("dom-resizeable");

// use as ES module
import Resize from "dom-resizeable";

// create resize control ui
const resizeControl = new Resize(document.body, {
  width: 100,
  height: 100,
  dragable: true,
});

const div = document.querySelector("#div");

// bind resize control ui to dom element
resizeControl.bindEditTarget(div);

API

const instance = new Resize(container, options);

// parent element for mount resize ui dom
container

// resize ui config
options = {
  width: 0, // ui control default width
  height: 0, // ui control default height
  draggable: false, // ui control can be drag move
  hideCheckIcon: false, // whether hide confirm icon
  handleSize: 8, // ui control handle size(px)

  onConfirm(e) {
    // confirm icon clicked
  },
}

instance.bindEditTarget(domElement, options)
// target dom element to resize
domElement

// element resize config
options = {
  lockAspectRatio: false, // whether lock aspect ratio when resizing
}