Skip to content

Instantly share code, notes, and snippets.

@subtubes-io
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save subtubes-io/b4bdcb779fe7da1ad711 to your computer and use it in GitHub Desktop.

Select an option

Save subtubes-io/b4bdcb779fe7da1ad711 to your computer and use it in GitHub Desktop.
define(function (require, exports, module) {
var OptionsManager = require('famous/core/OptionsManager');
var MouseSync = require("famous/inputs/MouseSync");
var sync = new MouseSync();
function Draggable(options) {
this.options = Object.create(Draggable.DEFAULT_OPTIONS);
this._optionsManager = new OptionsManager(this.options);
if (options) this.setOptions(options);
this._node = undefined;
}
Draggable.DEFAULT_OPTIONS = {};
Draggable.prototype.setNode = function (node, position) {
this._node = node;
this._node.pipe(sync);
sync.on('update', function (data) {
var currentPosition = position.get();
position.set([
currentPosition[0] + data.delta[0],
currentPosition[1] + data.delta[1]
]);
});
};
Draggable.prototype.render = function render() {
return {
origin: [.5, .5],
align: [.5, .5],
target: [this._node.render()]
}
};
module.exports = Draggable;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment