Code Monkey home page Code Monkey logo

ractive-drag-events's Introduction

ractive-drag-events

Adds HTML5 drag/drop proxy events to a Ractive element.

Code is loosely inspired by these updates to this module. Difference with this module is that it applies events to a given element rather than to all its children, and it doesn't clobber the element's draggable attribute.

Usage

  1. Require or include Ractive and this project
  2. Add on-dragndrop='foo' to something in the template
  3. Add ractive.on('foo', fn) in your source

Example

	var ractive = new Ractive({
		el: '#container',
		template: '<div on-dragndrop="DND" draggable="true">{{text}}</div>',
		data: {
			text: 'Drag me!'
		}
	})
	
	ractive.on('DND', function(event) {
		console.log(event)
	}

See live demo or example/index.html for a full example.

Event Object

  • type - One of: [ start, enter, over, leave, drop, end ]
  • context - Ractive context of the event item
  • keypath - Ractive keypath of the event item
  • node - HTML element of the event item
  • original - the original DOM MouseEvent

Note that the event item is the item being dragged for start/end events, and the item you're dragging to for all the others.

ractive-drag-events's People

Contributors

fenomas avatar

Stargazers

Bruno Babic avatar  avatar RYeah Sh avatar Gary Thomas avatar

Watchers

 avatar

Forkers

tehshrike

ractive-drag-events's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.