movable-resizable-js
This project is a javascript library to facilitate movable and resizable interaction on web page. The library is provided by Tencent Real-timing Communication(TRTC) team.
Installation
npm install movable-resizable-js
yarn add movable-resizable-js
Usage
Javascript
import { Movable, Resizable } from 'movable-resizable-js';
const targetElement = document.getElementById('movable-and-resiable');
const targetContainer = document.body;
const movableController = new Movable(
targetElement,
targetContainer,
{
canExceedContainer: true,
}
);
movableController.on('move', (left, top) => {
console.log('element moved to:', left, top);
});
const resizableController = new Resizable(
targetElement,
targetContainer,
{
canExceedContainer: true,
keepRatio: true,
stopPropagation: true
}
);
resizableController.on('resize', (left, top, width, height) => {
console.log('element resized to:', left, top, width, height);
});
CSS/SCSS/LESS
@import "movable-resizable-js/resizable.css";