New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cytoscape-node-html-label

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cytoscape-node-html-label - npm Package Compare versions

Comparing version 1.0.0 to 1.0.3

2

bower.json
{
"name": "cytoscape-node-html-label",
"description": "labels for cytoscape nodes",
"main": "cytoscape-node-html-label.js",
"main": "./dist/cytoscape-node-html-label.js",
"dependencies": {

@@ -6,0 +6,0 @@ "cytoscape": "^3.0.0"

(function () {
"use strict";
var $$find = function (arr, predicate) {
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var length = arr.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = arr[i];
if (predicate.call(thisArg, value, i, arr)) {
return value;
}
}
return undefined;
};
var LabelElement = (function () {
function LabelElement(_a, params) {
var node = _a.node, baseClassName = _a.baseClassName, _b = _a.position, position = _b === void 0 ? null : _b,
_c = _a.data, data = _c === void 0 ? null : _c;
this.updateParams(params);
this._node = node;
this._baseElementClassName = baseClassName;
this.init();
if (data) {
this.updateData(data);
}
if (position) {
this.updatePosition(position);
}
}
LabelElement.prototype.updateParams = function (_a) {
var _b = _a.tpl, tpl = _b === void 0 ? function () {
return "";
} : _b, _c = _a.cssClass, cssClass = _c === void 0 ? null : _c, _d = _a.halign,
halign = _d === void 0 ? "center" : _d, _e = _a.valign, valign = _e === void 0 ? "center" : _e,
_f = _a.halignBox, halignBox = _f === void 0 ? "center" : _f, _g = _a.valignBox,
valignBox = _g === void 0 ? "center" : _g;
var _align = {
"top": -.5,
"left": -.5,
"center": 0,
"right": .5,
"bottom": .5
};
this._align = [
_align[halign],
_align[valign],
100 * (_align[halignBox] - 0.5),
100 * (_align[valignBox] - 0.5)
];
this.cssClass = cssClass;
this.tpl = tpl;
"use strict";
var $$find = function (arr, predicate) {
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var length = arr.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = arr[i];
if (predicate.call(thisArg, value, i, arr)) {
return value;
}
}
return undefined;
};
LabelElement.prototype.updateData = function (data) {
try {
this._node.innerHTML = this.tpl(data);
}
catch (err) {
console.error(err);
}
};
LabelElement.prototype.getNode = function () {
return this._node;
};
LabelElement.prototype.updatePosition = function (pos) {
this._renderPosition(pos);
};
LabelElement.prototype.init = function () {
this._node.setAttribute("class", this._baseElementClassName);
if (this.cssClass && this.cssClass.length) {
this._node.classList.add(this.cssClass);
}
};
LabelElement.prototype._renderPosition = function (position) {
var prev = this._position;
var x = position.x + this._align[0] * position.w;
var y = position.y + this._align[1] * position.h;
if (!prev || prev[0] !== x || prev[1] !== y) {
this._position = [x, y];
var valRel = "translate(" + this._align[2] + "%," + this._align[3] + "%) ";
var valAbs = "translate(" + x.toFixed(2) + "px," + y.toFixed(2) + "px) ";
var val = valRel + valAbs;
var stl = this._node.style;
stl.webkitTransform = val;
stl.msTransform = val;
stl.transform = val;
}
};
return LabelElement;
}());
var LabelContainer = (function () {
function LabelContainer(node) {
this._node = node;
this._cssWrap = 'cy-node-html-' + (+new Date());
this._cssElem = this._cssWrap + '__e';
this.addCssToDocument();
this._node.className = this._cssWrap;
this._elements = {};
}
var LabelElement = (function () {
function LabelElement(_a, params) {
var node = _a.node, baseClassName = _a.baseClassName, _b = _a.position,
position = _b === void 0 ? null : _b, _c = _a.data, data = _c === void 0 ? null : _c;
this.updateParams(params);
this._node = node;
this._baseElementClassName = baseClassName;
this.init();
if (data) {
this.updateData(data);
}
if (position) {
this.updatePosition(position);
}
}
LabelContainer.prototype.addOrUpdateElem = function (id, param, payload) {
if (payload === void 0) {
payload = {};
}
var cur = this._elements[id];
if (cur) {
cur.updateParams(param);
cur.updateData(payload.data);
cur.updatePosition(payload.position);
}
else {
var nodeElem = document.createElement('div');
this._node.appendChild(nodeElem);
this._elements[id] = new LabelElement({
node: nodeElem,
baseClassName: this._cssElem,
data: payload.data,
position: payload.position
}, param);
}
};
LabelContainer.prototype.removeElemById = function (id) {
this._node.removeChild(this._elements[id].getNode());
delete this._elements[id];
};
LabelContainer.prototype.updateElemPosition = function (id, position) {
var ele = this._elements[id];
if (ele) {
ele.updatePosition(position);
}
};
LabelContainer.prototype.updatePanZoom = function (_a) {
var pan = _a.pan, zoom = _a.zoom;
var val = "translate(" + pan.x + "px," + pan.y + "px) scale(" + zoom + ")";
var stl = this._node.style;
var origin = 'top left';
stl.webkitTransform = val;
stl.msTransform = val;
stl.transform = val;
stl.webkitTransformOrigin = origin;
stl.msTransformOrigin = origin;
stl.transformOrigin = origin;
};
LabelContainer.prototype.addCssToDocument = function () {
var stylesWrap = 'position:absolute;z-index:10;width:500px;pointer-events:none;margin:0;padding:0;border:0;outline:0';
var stylesElem = 'position:absolute';
document.querySelector('head').innerHTML +=
"<style>." + this._cssWrap + "{" + stylesWrap + "} ." + this._cssElem + "{" + stylesElem + "}</style>";
};
return LabelContainer;
}());
LabelElement.prototype.updateParams = function (_a) {
var _b = _a.tpl, tpl = _b === void 0 ? function () {
return "";
} : _b, _c = _a.cssClass, cssClass = _c === void 0 ? null : _c, _d = _a.halign,
halign = _d === void 0 ? "center" : _d, _e = _a.valign, valign = _e === void 0 ? "center" : _e,
_f = _a.halignBox, halignBox = _f === void 0 ? "center" : _f, _g = _a.valignBox,
valignBox = _g === void 0 ? "center" : _g;
var _align = {
"top": -.5,
"left": -.5,
"center": 0,
"right": .5,
"bottom": .5
};
this._align = [
_align[halign],
_align[valign],
100 * (_align[halignBox] - 0.5),
100 * (_align[valignBox] - 0.5)
];
this.cssClass = cssClass;
this.tpl = tpl;
};
LabelElement.prototype.updateData = function (data) {
try {
this._node.innerHTML = this.tpl(data);
}
catch (err) {
console.error(err);
}
};
LabelElement.prototype.getNode = function () {
return this._node;
};
LabelElement.prototype.updatePosition = function (pos) {
this._renderPosition(pos);
};
LabelElement.prototype.init = function () {
this._node.setAttribute("class", this._baseElementClassName);
if (this.cssClass && this.cssClass.length) {
this._node.classList.add(this.cssClass);
}
};
LabelElement.prototype._renderPosition = function (position) {
var prev = this._position;
var x = position.x + this._align[0] * position.w;
var y = position.y + this._align[1] * position.h;
if (!prev || prev[0] !== x || prev[1] !== y) {
this._position = [x, y];
var valRel = "translate(" + this._align[2] + "%," + this._align[3] + "%) ";
var valAbs = "translate(" + x.toFixed(2) + "px," + y.toFixed(2) + "px) ";
var val = valRel + valAbs;
var stl = this._node.style;
stl.webkitTransform = val;
stl.msTransform = val;
stl.transform = val;
}
};
return LabelElement;
}());
var LabelContainer = (function () {
function LabelContainer(node) {
this._node = node;
this._cssWrap = 'cy-node-html-' + (+new Date());
this._cssElem = this._cssWrap + '__e';
this.addCssToDocument();
this._node.className = this._cssWrap;
this._elements = {};
}
function cyNodeHtmlLabel(_cy, params) {
var _params = (!params || typeof params !== "object") ? [] : params;
var _lc = createLabelContainer();
_cy.one('render', function (e) {
createNodesCyHandler(e);
wrapCyHandler(e);
});
_cy.on('add', addCyHandler);
_cy.on('layoutstop', layoutstopHandler);
_cy.on('remove', removeCyHandler);
_cy.on('data', updateDataCyHandler);
_cy.on('pan zoom', wrapCyHandler);
_cy.on('drag', moveCyHandler);
return _cy;
LabelContainer.prototype.addOrUpdateElem = function (id, param, payload) {
if (payload === void 0) {
payload = {};
}
var cur = this._elements[id];
if (cur) {
cur.updateParams(param);
cur.updateData(payload.data);
cur.updatePosition(payload.position);
}
else {
var nodeElem = document.createElement('div');
this._node.appendChild(nodeElem);
this._elements[id] = new LabelElement({
node: nodeElem,
baseClassName: this._cssElem,
data: payload.data,
position: payload.position
}, param);
}
};
LabelContainer.prototype.removeElemById = function (id) {
if (this._elements[id]) {
this._node.removeChild(this._elements[id].getNode());
delete this._elements[id];
}
};
LabelContainer.prototype.updateElemPosition = function (id, position) {
var ele = this._elements[id];
if (ele) {
ele.updatePosition(position);
}
};
LabelContainer.prototype.updatePanZoom = function (_a) {
var pan = _a.pan, zoom = _a.zoom;
var val = "translate(" + pan.x + "px," + pan.y + "px) scale(" + zoom + ")";
var stl = this._node.style;
var origin = 'top left';
stl.webkitTransform = val;
stl.msTransform = val;
stl.transform = val;
stl.webkitTransformOrigin = origin;
stl.msTransformOrigin = origin;
stl.transformOrigin = origin;
};
LabelContainer.prototype.addCssToDocument = function () {
var stylesWrap = 'position:absolute;z-index:10;width:500px;pointer-events:none;margin:0;padding:0;border:0;outline:0';
var stylesElem = 'position:absolute';
document.querySelector('head').innerHTML +=
"<style>." + this._cssWrap + "{" + stylesWrap + "} ." + this._cssElem + "{" + stylesElem + "}</style>";
};
return LabelContainer;
}());
function createLabelContainer() {
var _cyContainer = _cy.container();
var _titlesContainer = document.createElement('div');
var _cyCanvas = _cyContainer.querySelector('canvas');
var cur = _cyContainer.querySelector('[class^="cy-node-html"]');
if (cur) {
_cyCanvas.parentNode.removeChild(cur);
}
_cyCanvas.parentNode.appendChild(_titlesContainer);
return new LabelContainer(_titlesContainer);
}
function cyNodeHtmlLabel(_cy, params) {
var _params = (!params || typeof params !== "object") ? [] : params;
var _lc = createLabelContainer();
_cy.one('render', function (e) {
createNodesCyHandler(e);
wrapCyHandler(e);
});
_cy.on('add', addCyHandler);
_cy.on('layoutstop', layoutstopHandler);
_cy.on('remove', removeCyHandler);
_cy.on('data', updateDataCyHandler);
_cy.on('pan zoom', wrapCyHandler);
_cy.on('drag', moveCyHandler);
return _cy;
function createNodesCyHandler(_a) {
var cy = _a.cy;
_params.forEach(function (x) {
cy.elements(x.query).forEach(function (d) {
if (d.isNode()) {
_lc.addOrUpdateElem(d.id(), x, {
position: getNodePosition(d),
data: d.data()
function createLabelContainer() {
var _cyContainer = _cy.container();
var _titlesContainer = document.createElement('div');
var _cyCanvas = _cyContainer.querySelector('canvas');
var cur = _cyContainer.querySelector('[class^="cy-node-html"]');
if (cur) {
_cyCanvas.parentNode.removeChild(cur);
}
_cyCanvas.parentNode.appendChild(_titlesContainer);
return new LabelContainer(_titlesContainer);
}
function createNodesCyHandler(_a) {
var cy = _a.cy;
_params.forEach(function (x) {
cy.elements(x.query).forEach(function (d) {
if (d.isNode()) {
_lc.addOrUpdateElem(d.id(), x, {
position: getNodePosition(d),
data: d.data()
});
}
});
});
}
});
});
}
}
function addCyHandler(ev) {
var target = ev.target;
var param = $$find(_params.slice().reverse(), function (x) {
return target.is(x.query);
});
if (param) {
_lc.addOrUpdateElem(target.id(), param, {
position: getNodePosition(target),
data: target.data()
});
}
}
function addCyHandler(ev) {
var target = ev.target;
var param = $$find(_params.slice().reverse(), function (x) {
return target.is(x.query);
});
if (param) {
_lc.addOrUpdateElem(target.id(), param, {
position: getNodePosition(target),
data: target.data()
});
}
}
function layoutstopHandler(_a) {
var cy = _a.cy;
_params.forEach(function (x) {
cy.elements(x.query).forEach(function (d) {
if (d.isNode()) {
_lc.updateElemPosition(d.id(), getNodePosition(d));
}
});
});
}
function layoutstopHandler(_a) {
var cy = _a.cy;
_params.forEach(function (x) {
cy.elements(x.query).forEach(function (d) {
if (d.isNode()) {
_lc.updateElemPosition(d.id(), getNodePosition(d));
}
});
});
}
function removeCyHandler(ev) {
_lc.removeElemById(ev.target.id());
}
function removeCyHandler(ev) {
_lc.removeElemById(ev.target.id());
}
function moveCyHandler(ev) {
_lc.updateElemPosition(ev.target.id(), getNodePosition(ev.target));
}
function moveCyHandler(ev) {
_lc.updateElemPosition(ev.target.id(), getNodePosition(ev.target));
}
function updateDataCyHandler(ev) {
setTimeout(function () {
var target = ev.target;
var param = $$find(_params.slice().reverse(), function (x) {
return target.is(x.query);
});
if (param) {
_lc.addOrUpdateElem(target.id(), param, {
position: getNodePosition(target),
data: target.data()
});
function updateDataCyHandler(ev) {
setTimeout(function () {
var target = ev.target;
var param = $$find(_params.slice().reverse(), function (x) {
return target.is(x.query);
});
if (param) {
_lc.addOrUpdateElem(target.id(), param, {
position: getNodePosition(target),
data: target.data()
});
}
else {
_lc.removeElemById(target.id());
}
}, 0);
}
else {
_lc.removeElemById(target.id());
function wrapCyHandler(_a) {
var cy = _a.cy;
_lc.updatePanZoom({
pan: cy.pan(),
zoom: cy.zoom()
});
}
}, 0);
}
function wrapCyHandler(_a) {
var cy = _a.cy;
_lc.updatePanZoom({
pan: cy.pan(),
zoom: cy.zoom()
});
function getNodePosition(node) {
return {
w: node.width(),
h: node.height(),
x: node.position('x'),
y: node.position('y')
};
}
}
function getNodePosition(node) {
return {
w: node.width(),
h: node.height(),
x: node.position('x'),
y: node.position('y')
};
var register = function (cy) {
if (!cy) {
return;
}
cy('core', 'nodeHtmlLabel', function (optArr) {
return cyNodeHtmlLabel(this, optArr);
});
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = function (cy) {
register(cy);
};
}
}
var register = function (cy) {
if (!cy) {
return;
else {
if (typeof define !== 'undefined' && define.amd) {
define('cytoscape-nodeHtmlLabel', function () {
return register;
});
}
}
cy('core', 'nodeHtmlLabel', function (optArr) {
return cyNodeHtmlLabel(this, optArr);
});
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = function (cy) {
register(cy);
};
}
else {
if (typeof define !== 'undefined' && define.amd) {
define('cytoscape-nodeHtmlLabel', function () {
return register;
});
if (typeof cytoscape !== 'undefined') {
register(cytoscape);
}
}
if (typeof cytoscape !== 'undefined') {
register(cytoscape);
}
}());

@@ -1,1 +0,1 @@

!function(){"use strict";function t(t,n){function i(t){var e=t.cy;r.forEach(function(t){e.elements(t.query).forEach(function(e){e.isNode()&&d.addOrUpdateElem(e.id(),t,{position:a(e),data:e.data()})})})}function s(t){var e=t.cy;d.updatePanZoom({pan:e.pan(),zoom:e.zoom()})}function a(t){return{w:t.width(),h:t.height(),x:t.position("x"),y:t.position("y")}}var r=n&&"object"==typeof n?n:[],d=function(){var e=t.container(),n=document.createElement("div"),i=e.querySelector("canvas"),s=e.querySelector('[class^="cy-node-html"]');return s&&i.parentNode.removeChild(s),i.parentNode.appendChild(n),new o(n)}();return t.one("render",function(t){i(t),s(t)}),t.on("add",function(t){var n=t.target,o=e(r.slice().reverse(),function(t){return n.is(t.query)});o&&d.addOrUpdateElem(n.id(),o,{position:a(n),data:n.data()})}),t.on("layoutstop",function(t){var e=t.cy;r.forEach(function(t){e.elements(t.query).forEach(function(t){t.isNode()&&d.updateElemPosition(t.id(),a(t))})})}),t.on("remove",function(t){d.removeElemById(t.target.id())}),t.on("data",function(t){setTimeout(function(){var n=t.target,o=e(r.slice().reverse(),function(t){return n.is(t.query)});o?d.addOrUpdateElem(n.id(),o,{position:a(n),data:n.data()}):d.removeElemById(n.id())},0)}),t.on("pan zoom",s),t.on("drag",function(t){d.updateElemPosition(t.target.id(),a(t.target))}),t}var e=function(t,e){if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n,o=t.length>>>0,i=arguments[1],s=0;s<o;s++)if(n=t[s],e.call(i,n,s,t))return n},n=function(){function t(t,e){var n=t.node,o=t.baseClassName,i=t.position,s=void 0===i?null:i,a=t.data,r=void 0===a?null:a;this.updateParams(e),this._node=n,this._baseElementClassName=o,this.init(),r&&this.updateData(r),s&&this.updatePosition(s)}return t.prototype.updateParams=function(t){var e=t.tpl,n=void 0===e?function(){return""}:e,o=t.cssClass,i=void 0===o?null:o,s=t.halign,a=void 0===s?"center":s,r=t.valign,d=void 0===r?"center":r,c=t.halignBox,u=void 0===c?"center":c,l=t.valignBox,p=void 0===l?"center":l,f={top:-.5,left:-.5,center:0,right:.5,bottom:.5};this._align=[f[a],f[d],100*(f[u]-.5),100*(f[p]-.5)],this.cssClass=i,this.tpl=n},t.prototype.updateData=function(t){try{this._node.innerHTML=this.tpl(t)}catch(t){console.error(t)}},t.prototype.getNode=function(){return this._node},t.prototype.updatePosition=function(t){this._renderPosition(t)},t.prototype.init=function(){this._node.setAttribute("class",this._baseElementClassName),this.cssClass&&this.cssClass.length&&this._node.classList.add(this.cssClass)},t.prototype._renderPosition=function(t){var e=this._position,n=t.x+this._align[0]*t.w,o=t.y+this._align[1]*t.h;if(!e||e[0]!==n||e[1]!==o){this._position=[n,o];var i="translate("+this._align[2]+"%,"+this._align[3]+"%) "+("translate("+n.toFixed(2)+"px,"+o.toFixed(2)+"px) "),s=this._node.style;s.webkitTransform=i,s.msTransform=i,s.transform=i}},t}(),o=function(){function t(t){this._node=t,this._cssWrap="cy-node-html-"+ +new Date,this._cssElem=this._cssWrap+"__e",this.addCssToDocument(),this._node.className=this._cssWrap,this._elements={}}return t.prototype.addOrUpdateElem=function(t,e,o){void 0===o&&(o={});var i=this._elements[t];if(i)i.updateParams(e),i.updateData(o.data),i.updatePosition(o.position);else{var s=document.createElement("div");this._node.appendChild(s),this._elements[t]=new n({node:s,baseClassName:this._cssElem,data:o.data,position:o.position},e)}},t.prototype.removeElemById=function(t){this._node.removeChild(this._elements[t].getNode()),delete this._elements[t]},t.prototype.updateElemPosition=function(t,e){var n=this._elements[t];n&&n.updatePosition(e)},t.prototype.updatePanZoom=function(t){var e=t.pan,n=t.zoom,o="translate("+e.x+"px,"+e.y+"px) scale("+n+")",i=this._node.style;i.webkitTransform=o,i.msTransform=o,i.transform=o,i.webkitTransformOrigin="top left",i.msTransformOrigin="top left",i.transformOrigin="top left"},t.prototype.addCssToDocument=function(){document.querySelector("head").innerHTML+="<style>."+this._cssWrap+"{position:absolute;z-index:10;width:500px;pointer-events:none;margin:0;padding:0;border:0;outline:0} ."+this._cssElem+"{position:absolute}</style>"},t}(),i=function(e){e&&e("core","nodeHtmlLabel",function(e){return t(this,e)})};"undefined"!=typeof module&&module.exports?module.exports=function(t){i(t)}:"undefined"!=typeof define&&define.amd&&define("cytoscape-nodeHtmlLabel",function(){return i}),"undefined"!=typeof cytoscape&&i(cytoscape)}();
!function(){"use strict";function t(t,n){function i(t){var e=t.cy;r.forEach(function(t){e.elements(t.query).forEach(function(e){e.isNode()&&d.addOrUpdateElem(e.id(),t,{position:a(e),data:e.data()})})})}function s(t){var e=t.cy;d.updatePanZoom({pan:e.pan(),zoom:e.zoom()})}function a(t){return{w:t.width(),h:t.height(),x:t.position("x"),y:t.position("y")}}var r=n&&"object"==typeof n?n:[],d=function(){var e=t.container(),n=document.createElement("div"),i=e.querySelector("canvas"),s=e.querySelector('[class^="cy-node-html"]');return s&&i.parentNode.removeChild(s),i.parentNode.appendChild(n),new o(n)}();return t.one("render",function(t){i(t),s(t)}),t.on("add",function(t){var n=t.target,o=e(r.slice().reverse(),function(t){return n.is(t.query)});o&&d.addOrUpdateElem(n.id(),o,{position:a(n),data:n.data()})}),t.on("layoutstop",function(t){var e=t.cy;r.forEach(function(t){e.elements(t.query).forEach(function(t){t.isNode()&&d.updateElemPosition(t.id(),a(t))})})}),t.on("remove",function(t){d.removeElemById(t.target.id())}),t.on("data",function(t){setTimeout(function(){var n=t.target,o=e(r.slice().reverse(),function(t){return n.is(t.query)});o?d.addOrUpdateElem(n.id(),o,{position:a(n),data:n.data()}):d.removeElemById(n.id())},0)}),t.on("pan zoom",s),t.on("drag",function(t){d.updateElemPosition(t.target.id(),a(t.target))}),t}var e=function(t,e){if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n,o=t.length>>>0,i=arguments[1],s=0;s<o;s++)if(n=t[s],e.call(i,n,s,t))return n},n=function(){function t(t,e){var n=t.node,o=t.baseClassName,i=t.position,s=void 0===i?null:i,a=t.data,r=void 0===a?null:a;this.updateParams(e),this._node=n,this._baseElementClassName=o,this.init(),r&&this.updateData(r),s&&this.updatePosition(s)}return t.prototype.updateParams=function(t){var e=t.tpl,n=void 0===e?function(){return""}:e,o=t.cssClass,i=void 0===o?null:o,s=t.halign,a=void 0===s?"center":s,r=t.valign,d=void 0===r?"center":r,c=t.halignBox,l=void 0===c?"center":c,u=t.valignBox,p=void 0===u?"center":u,f={top:-.5,left:-.5,center:0,right:.5,bottom:.5};this._align=[f[a],f[d],100*(f[l]-.5),100*(f[p]-.5)],this.cssClass=i,this.tpl=n},t.prototype.updateData=function(t){try{this._node.innerHTML=this.tpl(t)}catch(t){console.error(t)}},t.prototype.getNode=function(){return this._node},t.prototype.updatePosition=function(t){this._renderPosition(t)},t.prototype.init=function(){this._node.setAttribute("class",this._baseElementClassName),this.cssClass&&this.cssClass.length&&this._node.classList.add(this.cssClass)},t.prototype._renderPosition=function(t){var e=this._position,n=t.x+this._align[0]*t.w,o=t.y+this._align[1]*t.h;if(!e||e[0]!==n||e[1]!==o){this._position=[n,o];var i="translate("+this._align[2]+"%,"+this._align[3]+"%) "+("translate("+n.toFixed(2)+"px,"+o.toFixed(2)+"px) "),s=this._node.style;s.webkitTransform=i,s.msTransform=i,s.transform=i}},t}(),o=function(){function t(t){this._node=t,this._cssWrap="cy-node-html-"+ +new Date,this._cssElem=this._cssWrap+"__e",this.addCssToDocument(),this._node.className=this._cssWrap,this._elements={}}return t.prototype.addOrUpdateElem=function(t,e,o){void 0===o&&(o={});var i=this._elements[t];if(i)i.updateParams(e),i.updateData(o.data),i.updatePosition(o.position);else{var s=document.createElement("div");this._node.appendChild(s),this._elements[t]=new n({node:s,baseClassName:this._cssElem,data:o.data,position:o.position},e)}},t.prototype.removeElemById=function(t){this._elements[t]&&(this._node.removeChild(this._elements[t].getNode()),delete this._elements[t])},t.prototype.updateElemPosition=function(t,e){var n=this._elements[t];n&&n.updatePosition(e)},t.prototype.updatePanZoom=function(t){var e=t.pan,n=t.zoom,o="translate("+e.x+"px,"+e.y+"px) scale("+n+")",i=this._node.style;i.webkitTransform=o,i.msTransform=o,i.transform=o,i.webkitTransformOrigin="top left",i.msTransformOrigin="top left",i.transformOrigin="top left"},t.prototype.addCssToDocument=function(){document.querySelector("head").innerHTML+="<style>."+this._cssWrap+"{position:absolute;z-index:10;width:500px;pointer-events:none;margin:0;padding:0;border:0;outline:0} ."+this._cssElem+"{position:absolute}</style>"},t}(),i=function(e){e&&e("core","nodeHtmlLabel",function(e){return t(this,e)})};"undefined"!=typeof module&&module.exports?module.exports=function(t){i(t)}:"undefined"!=typeof define&&define.amd&&define("cytoscape-nodeHtmlLabel",function(){return i}),"undefined"!=typeof cytoscape&&i(cytoscape)}();
{
"name": "cytoscape-node-html-label",
"version": "1.0.0",
"version": "1.0.3",
"description": "labels for cytoscape nodes",

@@ -5,0 +5,0 @@ "author": "Kalugin Sergey <kalugin.perm@gmail.com> (https://github.com/kaluginserg)",

@@ -116,4 +116,6 @@ (function () {

LabelContainer.prototype.removeElemById = function (id) {
this._node.removeChild(this._elements[id].getNode());
delete this._elements[id];
if (this._elements[id]) {
this._node.removeChild(this._elements[id].getNode());
delete this._elements[id];
}
};

@@ -120,0 +122,0 @@ LabelContainer.prototype.updateElemPosition = function (id, position) {

@@ -197,4 +197,6 @@ declare const require: any;

removeElemById(id: string) {
this._node.removeChild(this._elements[id].getNode());
delete this._elements[id];
if (this._elements[id]) {
this._node.removeChild(this._elements[id].getNode());
delete this._elements[id];
}
}

@@ -201,0 +203,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc