@layer5/cytoscape-node-html-label
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -1,3 +0,3 @@ | ||
declare type IHAlign = "left" | "center" | "right"; | ||
declare type IVAlign = "top" | "center" | "bottom"; | ||
type IHAlign = "left" | "center" | "right"; | ||
type IVAlign = "top" | "center" | "bottom"; | ||
declare var module: any; | ||
@@ -4,0 +4,0 @@ declare var define: any; |
@@ -21,2 +21,3 @@ (function () { | ||
var node = _a.node, _b = _a.position, position = _b === void 0 ? null : _b, _c = _a.data, data = _c === void 0 ? null : _c; | ||
this._defaultScale = 6; | ||
this.updateParams(params); | ||
@@ -81,3 +82,3 @@ this._node = node; | ||
var valRel = "translate(" + this._align[2] + "%," + this._align[3] + "%) "; | ||
var valAbs = "translate(" + x.toFixed(2) + "px," + y.toFixed(2) + "px) "; | ||
var valAbs = "translate(" + Number(x.toFixed(2)) * this._defaultScale + "px," + Number(y.toFixed(2)) * this._defaultScale + "px)"; | ||
var val = valRel + valAbs; | ||
@@ -96,2 +97,3 @@ var stl = this._node.style; | ||
this._elements = {}; | ||
this._defaultScale = 6; | ||
} | ||
@@ -130,3 +132,3 @@ LabelContainer.prototype.addOrUpdateElem = function (id, param, payload) { | ||
var pan = _a.pan, zoom = _a.zoom; | ||
var val = "translate(" + pan.x + "px," + pan.y + "px) scale(" + zoom + ")"; | ||
var val = "translate(" + pan.x + "px," + pan.y + "px) scale(" + zoom / this._defaultScale + ")"; | ||
var stl = this._node.style; | ||
@@ -133,0 +135,0 @@ var origin = "top left"; |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";function p(t,e){if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n,o=t.length>>>0,i=e,r=0;r<o;r++)if(n=t[r],e.call(i,n,r,t))return n}var r=(t.prototype.updateParams=function(t){var e=t.tpl,n=void 0===e?function(){return""}:e,o=(t.cssClass,t.halign),i=void 0===o?"center":o,r=t.valign,a=void 0===r?"center":r,s=t.halignBox,d=void 0===s?"center":s,p=t.valignBox,l=void 0===p?"center":p,u={top:-.5,left:-.5,center:0,right:.5,bottom:.5};this._align=[u[i],u[a],100*(u[d]-.5),100*(u[l]-.5)],this.tpl=n},t.prototype.updateData=function(t){for(;this._node.firstChild;)this._node.removeChild(this._node.firstChild);for(var e=(new DOMParser).parseFromString(this.tpl(t),"text/html").body.children,n=0;n<e.length;++n){var o=e[n];this._node.appendChild(o)}},t.prototype.getNode=function(){return this._node},t.prototype.updatePosition=function(t){this._renderPosition(t)},t.prototype.initStyles=function(t){this._node.style.position="absolute",t&&t.length&&this._node.classList.add(t)},t.prototype._renderPosition=function(t){var e,n,o=this._position,i=t.x+this._align[0]*t.w,r=t.y+this._align[1]*t.h;o&&o[0]===i&&o[1]===r||(this._position=[i,r],e="translate("+this._align[2]+"%,"+this._align[3]+"%) "+("translate("+i.toFixed(2)+"px,"+r.toFixed(2)+"px) "),(n=this._node.style).webkitTransform=e,n.msTransform=e,n.transform=e)},t);function t(t,e){var n=t.node,o=t.position,i=void 0===o?null:o,r=t.data,a=void 0===r?null:r;this.updateParams(e),this._node=n,this.initStyles(e.cssClass),a&&this.updateData(a),i&&this.updatePosition(i)}var l=(e.prototype.addOrUpdateElem=function(t,e,n){void 0===n&&(n={});var o,i=this._elements[t];i?(i.updateParams(e),i.updateData(n.data),i.updatePosition(n.position)):(o=document.createElement("div"),this._node.appendChild(o),this._elements[t]=new r({node:o,data:n.data,position:n.position},e))},e.prototype.removeElemById=function(t){this._elements[t]&&(this._node.removeChild(this._elements[t].getNode()),delete this._elements[t])},e.prototype.updateElemPosition=function(t,e){var n=this._elements[t];n&&n.updatePosition(e)},e.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,r="top left";i.webkitTransform=o,i.msTransform=o,i.transform=o,i.webkitTransformOrigin=r,i.msTransformOrigin=r,i.transformOrigin=r},e);function e(t){this._node=t,this._elements={}}function n(r,t,a){var o=t&&"object"==typeof t?t:[],i=function(){var t=r.container(),e=document.createElement("div"),n=t.querySelector("canvas"),o=t.querySelector("[class^='cy-node-html']");o&&n.parentNode.removeChild(o);var i=e.style;i.position="absolute",i["z-index"]=10,i.width="500px",i.margin="0px",i.padding="0px",i.border="0px",i.outline="0px",i.outline="0px",a&&!0!==a.enablePointerEvents&&(i["pointer-events"]="none");return n.parentNode.appendChild(e),new l(e)}();return r.one("render",function(t){var n;n=t.cy,o.forEach(function(e){n.elements(e.query).forEach(function(t){t.isNode()&&i.addOrUpdateElem(t.id(),e,{position:d(t),data:t.data()})})}),s(t)}),r.on("add",function(t){var e=t.target,n=p(o.slice().reverse(),function(t){return e.is(t.query)});n&&i.addOrUpdateElem(e.id(),n,{position:d(e),data:e.data()})}),r.on("layoutstop",function(t){var e=t.cy;o.forEach(function(t){e.elements(t.query).forEach(function(t){t.isNode()&&i.updateElemPosition(t.id(),d(t))})})}),r.on("remove",function(t){i.removeElemById(t.target.id())}),r.on("data",e),r.on("style",e),r.on("pan zoom",s),r.on("position bounds",function(t){i.updateElemPosition(t.target.id(),d(t.target))}),r;function e(n){setTimeout(function(){var e=n.target,t=p(o.slice().reverse(),function(t){return e.is(t.query)});t&&!e.removed()?i.addOrUpdateElem(e.id(),t,{position:d(e),data:e.data()}):i.removeElemById(e.id())},0)}function s(t){var e=t.cy;i.updatePanZoom({pan:e.pan(),zoom:e.zoom()})}function d(t){return{w:t.width(),h:t.height(),x:t.position("x"),y:t.position("y")}}}function o(t){t&&t("core","nodeHtmlLabel",function(t,e){return n(this,t,e)})}"undefined"!=typeof module&&module.exports?module.exports=function(t){o(t)}:"undefined"!=typeof define&&define.amd&&define("cytoscape-nodeHtmlLabel",function(){return o}),"undefined"!=typeof cytoscape&&o(cytoscape)}(); | ||
!function(){"use strict";var l=function(t,e){if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n,o=t.length>>>0,i=e,a=0;a<o;a++)if(n=t[a],e.call(i,n,a,t))return n},i=(t.prototype.updateParams=function(t){var e=t.tpl,e=void 0===e?function(){return""}:e,n=(t.cssClass,t.halign),o=t.valign,i=t.halignBox,t=t.valignBox,a={top:-.5,left:-.5,center:0,right:.5,bottom:.5};this._align=[a[void 0===n?"center":n],a[void 0===o?"center":o],100*(a[void 0===i?"center":i]-.5),100*(a[void 0===t?"center":t]-.5)],this.tpl=e},t.prototype.updateData=function(t){for(;this._node.firstChild;)this._node.removeChild(this._node.firstChild);for(var e=(new DOMParser).parseFromString(this.tpl(t),"text/html").body.children,n=0;n<e.length;++n){var o=e[n];this._node.appendChild(o)}},t.prototype.getNode=function(){return this._node},t.prototype.updatePosition=function(t){this._renderPosition(t)},t.prototype.initStyles=function(t){this._node.style.position="absolute",t&&t.length&&this._node.classList.add(t)},t.prototype._renderPosition=function(t){var e=this._position,n=t.x+this._align[0]*t.w,t=t.y+this._align[1]*t.h;e&&e[0]===n&&e[1]===t||(this._position=[n,t],e="translate("+this._align[2]+"%,"+this._align[3]+"%) "+("translate("+Number(n.toFixed(2))*this._defaultScale+"px,"+Number(t.toFixed(2))*this._defaultScale+"px)"),(n=this._node.style).webkitTransform=e,n.msTransform=e,n.transform=e)},t);function t(t,e){var n=t.node,o=t.position,o=void 0===o?null:o,t=t.data,t=void 0===t?null:t;this._defaultScale=6,this.updateParams(e),this._node=n,this.initStyles(e.cssClass),t&&this.updateData(t),o&&this.updatePosition(o)}e.prototype.addOrUpdateElem=function(t,e,n){void 0===n&&(n={});var o=this._elements[t];o?(o.updateParams(e),o.updateData(n.data),o.updatePosition(n.position)):(o=document.createElement("div"),this._node.appendChild(o),this._elements[t]=new i({node:o,data:n.data,position:n.position},e))},e.prototype.removeElemById=function(t){this._elements[t]&&(this._node.removeChild(this._elements[t].getNode()),delete this._elements[t])},e.prototype.updateElemPosition=function(t,e){t=this._elements[t];t&&t.updatePosition(e)},e.prototype.updatePanZoom=function(t){var e=t.pan,t=t.zoom,e="translate("+e.x+"px,"+e.y+"px) scale("+t/this._defaultScale+")",t=this._node.style,n="top left";t.webkitTransform=e,t.msTransform=e,t.transform=e,t.webkitTransformOrigin=n,t.msTransformOrigin=n,t.transformOrigin=n};var p=e;function e(t){this._node=t,this._elements={},this._defaultScale=6}function n(o,t,i){var a=t&&"object"==typeof t?t:[],r=function(){var t=o.container(),e=document.createElement("div"),n=t.querySelector("canvas"),t=t.querySelector("[class^='cy-node-html']");t&&n.parentNode.removeChild(t);t=e.style;t.position="absolute",t["z-index"]=10,t.width="500px",t.margin="0px",t.padding="0px",t.border="0px",t.outline="0px",t.outline="0px",i&&!0!==i.enablePointerEvents&&(t["pointer-events"]="none");return n.parentNode.appendChild(e),new p(e)}();return o.one("render",function(t){var n;n=t.cy,a.forEach(function(e){n.elements(e.query).forEach(function(t){t.isNode()&&r.addOrUpdateElem(t.id(),e,{position:d(t),data:t.data()})})}),s(t)}),o.on("add",function(t){var e=t.target,t=l(a.slice().reverse(),function(t){return e.is(t.query)});t&&r.addOrUpdateElem(e.id(),t,{position:d(e),data:e.data()})}),o.on("layoutstop",function(t){var e=t.cy;a.forEach(function(t){e.elements(t.query).forEach(function(t){t.isNode()&&r.updateElemPosition(t.id(),d(t))})})}),o.on("remove",function(t){r.removeElemById(t.target.id())}),o.on("data",e),o.on("style",e),o.on("pan zoom",s),o.on("position bounds",function(t){r.updateElemPosition(t.target.id(),d(t.target))}),o;function e(n){setTimeout(function(){var e=n.target,t=l(a.slice().reverse(),function(t){return e.is(t.query)});t&&!e.removed()?r.addOrUpdateElem(e.id(),t,{position:d(e),data:e.data()}):r.removeElemById(e.id())},0)}function s(t){t=t.cy;r.updatePanZoom({pan:t.pan(),zoom:t.zoom()})}function d(t){return{w:t.width(),h:t.height(),x:t.position("x"),y:t.position("y")}}}function o(t){t&&t("core","nodeHtmlLabel",function(t,e){return n(this,t,e)})}"undefined"!=typeof module&&module.exports?module.exports=function(t){o(t)}:"undefined"!=typeof define&&define.amd&&define("cytoscape-nodeHtmlLabel",function(){return o}),"undefined"!=typeof cytoscape&&o(cytoscape)}(); |
{ | ||
"name": "@layer5/cytoscape-node-html-label", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Add html labels to cytoscape nodes", | ||
"main": "gulpfile.js", | ||
"directories": { | ||
"test": "test" | ||
"author": "Layer5, Inc.", | ||
"main": "./dist/cytoscape-node-html-label.js", | ||
"spm": { | ||
"main": "./dist/cytoscape-node-html-label.js" | ||
}, | ||
"scripts": { | ||
"test": "npm run test" | ||
"test": "gulp test", | ||
"test-firefox": "TEST_ON_FIREFOX=true gulp test", | ||
"build": "tsc --declaration && gulp min", | ||
"lint": "eslint src --ext .ts", | ||
"start": "tsc --watch --declaration" | ||
}, | ||
@@ -21,11 +26,37 @@ "repository": { | ||
], | ||
"author": "Layer5, Inc.", | ||
"license": "AGPL-3.0", | ||
"bugs": { | ||
"url": "https://github.com/layer5labs/cytoscape-node-html-label/issues" | ||
"url": "https://github.com/kaluginserg/cytoscape-node-html-label/issues" | ||
}, | ||
"homepage": "https://github.com/layer5labs/cytoscape-node-html-label#readme", | ||
"dependencies": { | ||
"devDependencies": { | ||
"@types/cytoscape": "^3.14.11", | ||
"@typescript-eslint/eslint-plugin": "^4.14.1", | ||
"@typescript-eslint/parser": "^4.14.1", | ||
"eslint": "^7.18.0", | ||
"gulp": "^4.0.2", | ||
"gulp-bump": "^3.2.0", | ||
"gulp-git": "^2.10.1", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-tag-version": "^1.3.1", | ||
"gulp-uglify": "^3.0.2", | ||
"jasmine": "^2.7.0", | ||
"karma": "^1.7.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-firefox-launcher": "^1.0.4", | ||
"typescript": "^4.1.3", | ||
"cytoscape-node-html-label": "^1.2.2" | ||
} | ||
} | ||
}, | ||
"peerDependencies": { | ||
"@types/cytoscape": "^3.1.0", | ||
"cytoscape": "^3.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@types/cytoscape": { | ||
"optional": true | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -70,2 +70,3 @@ type IHAlign = "left" | "center" | "right"; | ||
private _align: [number, number, number, number]; | ||
private _defaultScale: number = 6; | ||
@@ -159,4 +160,5 @@ constructor({ | ||
const valRel = `translate(${this._align[2]}%,${this._align[3]}%) `; | ||
const valAbs = `translate(${x.toFixed(2)}px,${y.toFixed(2)}px) `; | ||
const valRel = "translate(" + this._align[2] + "%," + this._align[3] + "%) "; | ||
const valAbs = "translate(" + Number(x.toFixed(2))*this._defaultScale + "px," + Number(y.toFixed(2))*this._defaultScale + "px)"; | ||
const val = valRel + valAbs; | ||
@@ -179,2 +181,3 @@ const stl = <any>this._node.style; | ||
private _node: HTMLElement; | ||
private _defaultScale: number; | ||
@@ -184,2 +187,3 @@ constructor(node: HTMLElement) { | ||
this._elements = <HashTableElements>{}; | ||
this._defaultScale = 6; | ||
} | ||
@@ -220,3 +224,3 @@ | ||
updatePanZoom({pan, zoom}: { pan: { x: number, y: number }, zoom: number }) { | ||
const val = `translate(${pan.x}px,${pan.y}px) scale(${zoom})`; | ||
const val = "translate(" + pan.x + "px," + pan.y + "px) scale(" + zoom / this._defaultScale + ")"; | ||
const stl = <any>this._node.style; | ||
@@ -223,0 +227,0 @@ const origin = "top left"; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
561274
41
2740
0
2
18
1
+ Added@types/cytoscape@3.21.9(transitive)
- Removedcytoscape-node-html-label@^1.2.2
- Removedcytoscape-node-html-label@1.2.2(transitive)