I want to drag the Famous surface and return it to its original position when I let it go. I took the โDrag and Dropโ example and changed it, but when the mouseup is called back, it starts (I checked with console.log ) the modifier transformation is not. Here is the relevant code:
var surface = new Surface({ size: [200, 200], content: 'drag', properties: { backgroundColor: 'rgba(200, 200, 200, 0.5)', lineHeight: '200px', textAlign: 'center', cursor: 'pointer' } }); var draggable = new Draggable({ xRange: [-220, 220], yRange: [-220, 220] }); surface.pipe(draggable); var mod = new Modifier(); var trans = { method: 'snap', period: 300, dampingRatio: 0.3, velocity: 0 }; surface.on('mouseup', function() { mod.setTransform(Transform.translate(0, 0, 0), trans); }); mainContext.add(mod).add(draggable).add(surface);
Quite precisely, this is related to the order / way that I am add , at the end of their mainContext and the order in which events are mainContext . What am I doing wrong / misunderstanding?
Theodor vararu
source share