Hi all,
I'm trying to disable or kill a draggable element within an SVG. After calling disable() on the draggable, the onClick function still fires.
Other effects of disabling are as expected: the element can no longer be dragged, the "grab" cursor style is removed, the onDragEnd function no longer fires.
Have also tried kill(), with the same results.
Here's a minimal example, tested in Chrome and Firefox.
<svg version='1.1' xmlns="http://www.w3.org/2000/svg" x='0px' y='0px' viewBox='0 0 200 200'>
<rect x="0" y="0" width="50" height="50" class="draggable1"></rect>
</svg>
<script type="module">
import { gsap } from 'gsap'
import { Draggable } from "gsap/Draggable";
gsap.registerPlugin(Draggable);
Draggable.create(".draggable1", {
type:"x,y",
bounds: "svg",
onClick: function() {
console.log("clicked");
},
onDragEnd: function() {
console.log("drag ended");
}
});
Draggable.get(".draggable1").disable(); // onClick function still fires
</script>
Let me know if you need further info.
Cheers
Steve