0.1.1 • Published 8 years ago

ractive-drag-events v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

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.

0.1.1

8 years ago

0.1.0

9 years ago