<div dir="ltr"><div>First, to disable the normal behavior the morph already provides an interface.</div><div>You can just call</div><div><br></div><div><font face="courier new, monospace">morph.disableGrabbing();</font></div>
<div><br></div><div>to not pick up the morph when dragging on it.</div><div><br></div><div>Then, step 2, is to define the behavior of what to do instead. You can</div><div>overwrite the normal drag logic. First make sure dragging is enabled:</div>
<div><br></div><div><font face="courier new, monospace">morph.enableDragging();</font></div><div><br></div><div>There are three dragging-related event handlers:</div><div><br></div><div>onDragStart</div><div>onDrag</div><div>
onDragEnd</div><div><br></div><div>You need to implement the first two:</div><div><br></div><div><font face="courier new, monospace">morph.addScript(function onDrag(evt) {</font></div><div><font face="courier new, monospace"> var globalPosition = this.worldPoint(pt(0,0)),</font></div>
<div><font face="courier new, monospace"> nowHandAngle = evt.getPosition().subPt(globalPosition).theta(),</font></div><div><font face="courier new, monospace"> newRotation = this.startRotation + (nowHandAngle - this.startHandAngle);</font></div>
<div><font face="courier new, monospace"> this.setRotation(newRotation);</font></div><div><font face="courier new, monospace">});</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">morph.addScript(function onDragStart(evt) {</font></div>
<div><font face="courier new, monospace"> var globalPosition = this.worldPoint(pt(0,0));</font></div><div><font face="courier new, monospace"> this.startRotation = this.getRotation();</font></div><div><font face="courier new, monospace"> this.startHandAngle = evt.getPosition().subPt(globalPosition).theta();</font></div>
<div><font face="courier new, monospace">});</font></div><div><br></div><div>To make sure to rotate the center of the morph you probably want to set the</div><div>origin itself. You can do this when the morphs shows its halos by clicking and</div>
<div>dragging the little red dot around or programatically via</div><div><br></div><div><font face="courier new, monospace">morph.setOrigin(morph.innerBounds().center())</font></div></div>