tree-helper
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -15,5 +15,5 @@ /*! | ||
/*! | ||
* helper-js v1.0.0 | ||
* helper-js v1.0.6 | ||
* phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* undefined | ||
* https://github.com/phphe/helper-js.git | ||
* Released under the MIT License. | ||
@@ -54,67 +54,4 @@ */ | ||
} | ||
function getOffset(el) { | ||
var elOffset = { | ||
x: el.offsetLeft, | ||
y: el.offsetTop | ||
}; | ||
var parentOffset = { x: 0, y: 0 }; | ||
if (el.offsetParent != null) parentOffset = getOffset(el.offsetParent); | ||
return { | ||
x: elOffset.x + parentOffset.x, | ||
y: elOffset.y + parentOffset.y | ||
}; | ||
} | ||
// overload waitFor(condition, time = 100, maxCount = 1000)) | ||
function waitFor(name, condition) { | ||
var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100; | ||
var maxCount = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000; | ||
var storeOfWaitFor = {}; | ||
if (isFunction(name)) { | ||
maxCount = time; | ||
time = isNumeric(condition) ? condition : 100; | ||
condition = name; | ||
name = null; | ||
} | ||
if (!waitFor._waits) { | ||
waitFor._waits = {}; | ||
} | ||
var waits = waitFor._waits; | ||
if (name && isset(waits[name])) { | ||
window.clearInterval(waits[name]); | ||
delete waits[name]; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var count = 0; | ||
function judge(interval) { | ||
if (count <= maxCount) { | ||
if (condition()) { | ||
stop(interval, name); | ||
resolve(); | ||
} | ||
} else { | ||
stop(interval, name); | ||
reject(new Error('waitFor: Limit is reached')); | ||
} | ||
count++; | ||
} | ||
function stop(interval, name) { | ||
if (interval) { | ||
if (name && isset(waits[name])) { | ||
window.clearInterval(waits[name]); | ||
delete waits[name]; | ||
} else { | ||
window.clearInterval(interval); | ||
} | ||
} | ||
} | ||
var interval = window.setInterval(function () { | ||
judge(interval); | ||
}, time); | ||
if (name) { | ||
waits[name] = interval; | ||
} | ||
judge(); | ||
}); | ||
} | ||
function clone(obj) { | ||
@@ -121,0 +58,0 @@ var childrenKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children'; |
{ | ||
"name": "tree-helper", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -24,4 +24,4 @@ "main": "dist/tree-helper.common.js", | ||
"dependencies": { | ||
"helper-js": "^1.0.3" | ||
"helper-js": "^1.0.6" | ||
} | ||
} |
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
23568
494
Updatedhelper-js@^1.0.6