Sha256: 4800d7bbad86bdd51ae2ee61b68e9f9968310d76e85c54f74e46f6385fe86c0c

Contents?: true

Size: 679 Bytes

Versions: 2

Compression:

Stored size: 679 Bytes

Contents

/*
The drag component adds functions to move points
in relation to its starting postion.
*/
re.c('drag')
.defaults({
	posX:0,
	posY:0,
	
	dragX:0,
	dragY:0,
	
	dragging:false
})
.defines({
	
	dragStart:function(x, y){
		if(!this.dragging){
			this.dragging = true;
			this.dragX = x;
			this.dragY = y;
      this.trigger('drag:start');
		}
    return this;
	},
	
	dragEnd:function(){
		this.dragging = false;
    return this.trigger('drag:end');
	},
	
	dragUpdate:function(x, y){
		if(this.dragging){
			this.posX += x - this.dragX;
			this.posY += y - this.dragY;
			
			this.dragX = x;
			this.dragY = y;
      
      this.trigger('drag:update');
		}
    return this;
	}
	
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
entityjs-0.3.1 src/math/drag.js
entityjs-0.3.0 src/math/drag.js