Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-moveable

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-moveable

Simple and lightweight implementation of moveable API

  • 0.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

simple moveable

License Version Build Status

View this page in other languages:

Installation

npm

npm install --save simple-moveable

How to use

import moveable from "simple-moveable";

const moveableElement = new moveable(element,{
	resizable: true,
	draggable: true,
	directions: [s, se, e, ne, n, nw, w, sw,],
	/* set threshold value to increase the resize area */
	// threshold: { s: 5, se: 5, e: 5, ne: 5, n: 5, nw: 5, w: 5, sw: 5 },
	// threshold: { edge:5, corner:5 },
	threshold: 10,
	/**
	 * set thresholdPosition to decide where the resizable area is
	 * "in": the activated resizable area is within the target element
	 * "center": the activated resizable area is half within the target element and half out of the it
	 * "out": the activated resizable area is out of the target element
	 * a number(0~1): a ratio which determines the how much the the activated resizable area beyond the element
	 */
	// thresholdPosition: "in",
	// thresholdPosition: "center",
	// thresholdPosition: "out",
	thresholdPosition: 0.9
})
let startTranslate = [0, 0];
/* draggable events*/
moveableElement
.on("dragStart", ({ set }) => {
	set(startTranslate);
})
.on("drag", ({ target, translate }) => {
	startTranslate = translate;
	target.style.transform = `translate(${translate[0]}px,${translate[1]}px)`;
}).on("dragEnd",({ translate }) => {
	startTranslate = translate;
})
.on("resizeStart", ({ set }) => {
	set(startTranslate);
})
.on("resize", ({ target, width, height, translate, inputEvent }) => {
	target.style.width = `${width}px`;
	target.style.height = `${height}px`;
	target.style.transform = `translate(${translate[0]}px, ${translate[1]}px)`;
})
.on("resizeEnd", ({ translate, width, height, inputEvent, target }) => {
	startTranslate = translate;
	target.style.transform = `translate(${translate[0]}px, ${translate[1]}px)`;
});

Contact Us

E-mails: Mark Fenng

Keywords

FAQs

Package last updated on 16 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc