UNPKG

leo-vue

Version:

Use the Leo Outlining Editor to Create Vue Web Apps

52 lines (45 loc) 991 B
function compareString (a, b) { return (a < b) ? -1 : (a > b) ? 1 : 0 } function anchorTodx (d, el) { if (d === 'middle') { return -el.getBBox().width / 2 } else if (d === 'end') { return -(el.getBBox().width + 4) } return 0 } function findInParents (node, nodes) { if (nodes.indexOf(node) !== -1) { return node } const parent = node.parent return (parent === null) ? node : findInParents(parent, nodes) } function toPromise (transition) { let count = 0 let interrupted = false transition.each(() => count++) return new Promise(function (resolve, reject) { if (count === 0) { resolve('ended') return } const check = () => { if (--count === 0) { resolve(interrupted ? 'interrupted' : 'ended') } } transition.on('end', check) transition.on('interrupt', () => { interrupted = true check() }) }) } export { compareString, anchorTodx, toPromise, findInParents }