cytoscape-qtip
Advanced tools
Comparing version 2.2.3 to 2.2.4
{ | ||
"name": "cytoscape-qtip", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"main": "cytoscape-qtip.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
;(function( $, $$ ){ 'use strict'; | ||
var isObject = function(o){ | ||
return o != null && typeof o === 'object'; | ||
}; | ||
var isFunction = function(o){ | ||
return o != null && typeof o === 'function'; | ||
}; | ||
var isNumber = function(o){ | ||
return o != null && typeof o === 'number'; | ||
}; | ||
var throttle = function(func, wait, options) { | ||
var leading = true, | ||
trailing = true; | ||
if (options === false) { | ||
leading = false; | ||
} else if (isObject(options)) { | ||
leading = 'leading' in options ? options.leading : leading; | ||
trailing = 'trailing' in options ? options.trailing : trailing; | ||
} | ||
options = options || {}; | ||
options.leading = leading; | ||
options.maxWait = wait; | ||
options.trailing = trailing; | ||
return debounce(func, wait, options); | ||
}; | ||
var debounce = function(func, wait, options) { // ported lodash debounce function | ||
var args, | ||
maxTimeoutId, | ||
result, | ||
stamp, | ||
thisArg, | ||
timeoutId, | ||
trailingCall, | ||
lastCalled = 0, | ||
maxWait = false, | ||
trailing = true; | ||
if (!isFunction(func)) { | ||
return; | ||
} | ||
wait = Math.max(0, wait) || 0; | ||
if (options === true) { | ||
var leading = true; | ||
trailing = false; | ||
} else if (isObject(options)) { | ||
leading = options.leading; | ||
maxWait = 'maxWait' in options && (Math.max(wait, options.maxWait) || 0); | ||
trailing = 'trailing' in options ? options.trailing : trailing; | ||
} | ||
var delayed = function() { | ||
var remaining = wait - (Date.now() - stamp); | ||
if (remaining <= 0) { | ||
if (maxTimeoutId) { | ||
clearTimeout(maxTimeoutId); | ||
} | ||
var isCalled = trailingCall; | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (isCalled) { | ||
lastCalled = Date.now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
} | ||
} else { | ||
timeoutId = setTimeout(delayed, remaining); | ||
} | ||
}; | ||
var maxDelayed = function() { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (trailing || (maxWait !== wait)) { | ||
lastCalled = Date.now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
} | ||
}; | ||
return function() { | ||
args = arguments; | ||
stamp = Date.now(); | ||
thisArg = this; | ||
trailingCall = trailing && (timeoutId || !leading); | ||
if (maxWait === false) { | ||
var leadingCall = leading && !timeoutId; | ||
} else { | ||
if (!maxTimeoutId && !leading) { | ||
lastCalled = stamp; | ||
} | ||
var remaining = maxWait - (stamp - lastCalled), | ||
isCalled = remaining <= 0; | ||
if (isCalled) { | ||
if (maxTimeoutId) { | ||
maxTimeoutId = clearTimeout(maxTimeoutId); | ||
} | ||
lastCalled = stamp; | ||
result = func.apply(thisArg, args); | ||
} | ||
else if (!maxTimeoutId) { | ||
maxTimeoutId = setTimeout(maxDelayed, remaining); | ||
} | ||
} | ||
if (isCalled && timeoutId) { | ||
timeoutId = clearTimeout(timeoutId); | ||
} | ||
else if (!timeoutId && wait !== maxWait) { | ||
timeoutId = setTimeout(delayed, wait); | ||
} | ||
if (leadingCall) { | ||
isCalled = true; | ||
result = func.apply(thisArg, args); | ||
} | ||
if (isCalled && !timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
return result; | ||
}; | ||
}; | ||
function register( $$, $ ){ | ||
@@ -58,5 +189,5 @@ | ||
if( opts.content ){ | ||
if( $$.is.fn(opts.content) ){ | ||
if( isFunction(opts.content) ){ | ||
content = opts.content; | ||
} else if( opts.content.text && $$.is.fn(opts.content.text) ){ | ||
} else if( opts.content.text && isFunction(opts.content.text) ){ | ||
content = opts.content.text; | ||
@@ -119,7 +250,7 @@ } | ||
if( $$.is.number(adjNums.x) ){ | ||
if( isNumber(adjNums.x) ){ | ||
pos.x += adjNums.x; | ||
} | ||
if( $$.is.number(adjNums.y) ){ | ||
if( isNumber(adjNums.y) ){ | ||
pos.y += adjNums.y; | ||
@@ -145,3 +276,3 @@ } | ||
if( opts.hide.cyViewport ){ | ||
cy.on('viewport', $$.util.debounce(function(){ | ||
cy.on('viewport', debounce(function(){ | ||
qtipApi.hide(); | ||
@@ -152,3 +283,3 @@ }, viewportDebounceRate, { leading: true }) ); | ||
if( opts.position.adjust.cyViewport ){ | ||
cy.on('pan zoom', $$.util.debounce(function(e){ | ||
cy.on('pan zoom', debounce(function(e){ | ||
updatePosition(e); | ||
@@ -207,3 +338,3 @@ | ||
if( opts.hide.cyViewport ){ | ||
cy.on('viewport', $$.util.debounce(function(){ | ||
cy.on('viewport', debounce(function(){ | ||
qtipApi.hide(); | ||
@@ -210,0 +341,0 @@ }, viewportDebounceRate, { leading: true }) ); |
{ | ||
"name": "cytoscape-qtip", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "A Cytoscape.js extension that wraps the qTip jQuery library", | ||
@@ -5,0 +5,0 @@ "main": "cytoscape-qtip.js", |
Sorry, the diff of this file is not supported yet
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
34931
429