Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enableDrawing (enabled = true) {
if (enabled && (this.drawingable ? !interact.isSet(this.background.node) : true)) {
this.$_haveVNodeMoreThan(1, this.$slots.drawing, () => {
throw Error(`only 1 slot="drawing" allowed, you have ${this.$slots.drawing.length} slot="drawing"`)
})
this.background.style('cursor', 'crosshair')
let annotator
let attr = {}
this.drawingable = interact(this.background.node).styleCursor(false)
.draggable({
inertia: this.inertia,
snap: { targets: [this.gridTarget] },
restrict: 'svg', // allow drawing only in background element (outside annotation)
autoScroll: true,
onstart: event => {
annotator = SVG.adopt(this.$slots.drawing[0].elm).clone() // strange behaviour, shift() with drawing[0] will make error
componentWillUnmount() {
if (interact.isSet(this.node)) {
interact(this.node).unset();
}
window.removeEventListener("resize", this.resizeListener, false);
}