cytoscape-edgehandles
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -388,3 +388,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
presumptiveTargets = this.presumptiveTargets, | ||
previewEles = this.previewEles; | ||
previewEles = this.previewEles, | ||
active = this.active; | ||
@@ -396,3 +397,14 @@ | ||
var added = cy.collection(); | ||
var edgeType = options.edgeType(source, target); | ||
// can't make edges outside of regular gesture lifecycle | ||
if (!active) { | ||
return; | ||
} | ||
// must have a non-empty edge type | ||
if (!edgeType) { | ||
return; | ||
} | ||
// can't make preview if disabled | ||
@@ -437,4 +449,2 @@ if (preview && !options.preview) { | ||
var edgeType = options.edgeType(source, target); | ||
if (edgeType === 'node') { | ||
@@ -727,9 +737,4 @@ var interNode = cy.add(addClassesToEleJson(assign({ | ||
function hide() { | ||
var cy = this.cy; | ||
this.removeHandle(); | ||
this.sourceNode = cy.collection(); | ||
this.emit('hide', this.hp(), this.sourceNode); | ||
@@ -773,6 +778,2 @@ | ||
if (!this.active || target.same(this.handleNode)) { | ||
return; | ||
} | ||
var options = this.options, | ||
@@ -782,14 +783,19 @@ sourceNode = this.sourceNode, | ||
presumptiveTargets = this.presumptiveTargets, | ||
previewEles = this.previewEles; | ||
previewEles = this.previewEles, | ||
active = this.active; | ||
var source = sourceNode; | ||
var isLoop = target.same(source); | ||
var loopAllowed = options.loopAllowed(target); | ||
var isGhost = target.same(ghostNode); | ||
var noEdge = !options.edgeType(source, target); | ||
var isHandle = target.same(this.handleNode); | ||
if (!active || isHandle || isGhost || noEdge) { | ||
return; | ||
} | ||
clearTimeout(this.previewTimeout); | ||
this.previewTimeout = setTimeout(function () { | ||
var isLoop = target.same(source); | ||
var loopAllowed = options.loopAllowed(target); | ||
var isGhost = target.same(ghostNode); | ||
var noEdge = options.edgeType(source, target) == null; | ||
_this.targetNode = target; | ||
@@ -800,6 +806,2 @@ presumptiveTargets.merge(target); | ||
if (isGhost || noEdge) { | ||
return; | ||
} | ||
if (!isLoop || isLoop && loopAllowed) { | ||
@@ -863,6 +865,2 @@ target.addClass('eh-target'); | ||
this.active = false; | ||
this.makeEdges(); | ||
sourceNode.removeClass('eh-source'); | ||
@@ -872,2 +870,4 @@ targetNode.removeClass('eh-target eh-preview eh-hover'); | ||
this.makeEdges(); | ||
this.removeHandle(); | ||
@@ -881,2 +881,4 @@ | ||
this.active = false; | ||
this.emit('stop', this.mp(), sourceNode); | ||
@@ -883,0 +885,0 @@ |
{ | ||
"name": "cytoscape-edgehandles", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Edge creation UI extension for Cytoscape", | ||
@@ -5,0 +5,0 @@ "main": "cytoscape-edgehandles.js", |
@@ -14,3 +14,3 @@ const assign = require('../assign'); | ||
function makeEdges( preview = false ) { | ||
let { cy, options, presumptiveTargets, previewEles } = this; | ||
let { cy, options, presumptiveTargets, previewEles, active } = this; | ||
@@ -21,3 +21,10 @@ let source = this.sourceNode; | ||
let added = cy.collection(); | ||
let edgeType = options.edgeType( source, target ); | ||
// can't make edges outside of regular gesture lifecycle | ||
if( !active ){ return; } | ||
// must have a non-empty edge type | ||
if( !edgeType ){ return; } | ||
// can't make preview if disabled | ||
@@ -60,4 +67,2 @@ if( preview && !options.preview ){ return; } | ||
let edgeType = options.edgeType( source, target ); | ||
if( edgeType === 'node' ){ | ||
@@ -64,0 +69,0 @@ let interNode = cy.add( |
@@ -40,8 +40,4 @@ function canStartOn( node ){ | ||
function hide(){ | ||
let { cy } = this; | ||
this.removeHandle(); | ||
this.sourceNode = cy.collection(); | ||
this.emit( 'hide', this.hp(), this.sourceNode ); | ||
@@ -78,16 +74,16 @@ | ||
function preview( target ) { | ||
if( !this.active || target.same( this.handleNode ) ){ return; } | ||
let { options, sourceNode, ghostNode, presumptiveTargets, previewEles } = this; | ||
function preview( target ){ | ||
let { options, sourceNode, ghostNode, presumptiveTargets, previewEles, active } = this; | ||
let source = sourceNode; | ||
let isLoop = target.same( source ); | ||
let loopAllowed = options.loopAllowed( target ); | ||
let isGhost = target.same( ghostNode ); | ||
let noEdge = !options.edgeType( source, target ); | ||
let isHandle = target.same( this.handleNode ); | ||
if( !active || isHandle || isGhost || noEdge ) { return; } | ||
clearTimeout( this.previewTimeout ); | ||
this.previewTimeout = setTimeout( () => { | ||
let isLoop = target.same( source ); | ||
let loopAllowed = options.loopAllowed( target ); | ||
let isGhost = target.same( ghostNode ); | ||
let noEdge = options.edgeType( source, target ) == null; | ||
this.targetNode = target; | ||
@@ -98,4 +94,2 @@ presumptiveTargets.merge( target ); | ||
if( isGhost || noEdge ) { return; } | ||
if( !isLoop || ( isLoop && loopAllowed ) ) { | ||
@@ -147,6 +141,2 @@ target.addClass('eh-target'); | ||
this.active = false; | ||
this.makeEdges(); | ||
sourceNode.removeClass('eh-source'); | ||
@@ -156,2 +146,4 @@ targetNode.removeClass('eh-target eh-preview eh-hover'); | ||
this.makeEdges(); | ||
this.removeHandle(); | ||
@@ -165,2 +157,4 @@ | ||
this.active = false; | ||
this.emit( 'stop', this.mp(), sourceNode ); | ||
@@ -167,0 +161,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121392
1567