Last active
August 29, 2015 14:01
-
-
Save subtubes-io/b4bdcb779fe7da1ad711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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