npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

drag-drop-stage-component

v1.0.35

Published

A component to "drag'n drop"-enable your projects, maintained and simple, light on dependencies

Downloads

60

Readme

About this project

This "stage" component enables the user select elements, drag and drop them, resize them.

A component like this will be useful to the developer building any tool which includes a WYSIWYG.

This project is maintained, has very few dependencies and is used in Silex website builder

Here is a very simple example.

Features

  • [x] move and resize elements
  • [x] supports absolute position as well as elements in the flow
  • [x] multi selection
  • [x] shift + resize will keep proportions
  • [x] shift + move to stay aligned
  • [x] drawing mode, which let the user select multiple elements easily or draw a new element on the stage
  • [x] hooks give you full control over what is selectable, draggable, droppable, resizeable, a drop zone
  • [x] events to be notified of every action of the user
  • [x] scroll when the user moves near the border of the stage, or to show a specific element
  • [x] handle the events outside the iframe (the user can drag an element and release the mouse outside the iframe)
  • [x] sticky elements
  • [ ] vote and submit feature requests

Here is a list of features which is the current road map (please vote with :+1:s).

Use

See the online demo and its sources: html here and js here.

The component can be initialized like this, which will make it possible to select, move and resize all the elements marked with the .selectable css class.

// All the div in the iframe
const iframe = document.querySelector('#iframe')
const stage = new Stage(iframe, iframe.contentDocument.querySelectorAll('div'))

The iframe is where you add elements with the .selectable, .draggable, .resizeable, .droppable css classes, which can then be moved and resized.

Your application can catch events and store the new style of the elements after a drop.

stage.on('drop', e => {
	console.log('elements have been moved or resized, store their new styles if you wish', e.elements);
});

By default the elements which can be dragged or moved are those with the CSS classes .selectable,.draggable, .resizeable but you can override this as follow. The .droppable CSS class can be overrided too:

const stage = new Stage(iframe, {
	isSelectable: (el) => el.classList.contains('selectable'),
	isDroppable: (el, selection) => el.classList.contains('droppable'),
})

Build

The build requires nodejs and npm, and it produces these files:

  • pub/stage.js, which you need to include in your project
  • pub/stage.css, which will be included in the iframe to draw the UI
  • pub/demo.html, which is a demo page for you to test the component

Run npm install and npm run build to build these files.

Dependencies

This component only depenency is the redux library.

It uses Typescript to compile to Javscript and less to compile to CSS. Also the unit tests are written with Jest.

Contribute

Please vote for the features which matter to you here.

If you want to contribute code, read this readme for an introduction to the source code. And then you can help fixing the issues found in the code by Code Climat or find things to do in these issues which need to be done.

The source code is written in ES2015 with less and jade.