@cosmograph/cosmos
Advanced tools
Comparing version 1.6.0-beta.1 to 1.6.0-beta.2
@@ -329,3 +329,3 @@ import { D3ZoomEvent } from 'd3-zoom'; | ||
* Initial zoom level. Can be set once during graph initialization. | ||
* Default value: `1` | ||
* Default value: `undefined` | ||
*/ | ||
@@ -403,3 +403,3 @@ initialZoomLevel?: number; | ||
scaleNodesOnZoom: boolean; | ||
initialZoomLevel: number; | ||
initialZoomLevel: undefined; | ||
disableZoom: boolean; | ||
@@ -406,0 +406,0 @@ fitViewOnInit: boolean; |
@@ -41,3 +41,2 @@ export declare const defaultNodeColor = "#b3b3b3"; | ||
scaleNodesOnZoom: boolean; | ||
initialZoomLevel: number; | ||
disableZoom: boolean; | ||
@@ -44,0 +43,0 @@ fitViewOnInit: boolean; |
{ | ||
"name": "@cosmograph/cosmos", | ||
"version": "1.6.0-beta.1", | ||
"version": "1.6.0-beta.2", | ||
"description": "GPU-based force graph layout and rendering", | ||
@@ -56,3 +56,3 @@ "jsdelivr": "dist/index.min.js", | ||
"rollup-plugin-typescript2": "^0.32.1", | ||
"ttypescript": "^1.5.13", | ||
"ttypescript": "^1.5.15", | ||
"typescript": "^4.7.4" | ||
@@ -59,0 +59,0 @@ }, |
@@ -51,2 +51,3 @@ import path from 'path' | ||
} | ||
// eslint-disable-next-line import/no-default-export | ||
export default [ | ||
@@ -53,0 +54,0 @@ { |
@@ -359,3 +359,3 @@ import { D3ZoomEvent } from 'd3-zoom' | ||
* Initial zoom level. Can be set once during graph initialization. | ||
* Default value: `1` | ||
* Default value: `undefined` | ||
*/ | ||
@@ -464,3 +464,3 @@ initialZoomLevel?: number; | ||
public scaleNodesOnZoom = defaultConfigValues.scaleNodesOnZoom | ||
public initialZoomLevel = defaultConfigValues.initialZoomLevel | ||
public initialZoomLevel = undefined | ||
public disableZoom = defaultConfigValues.disableZoom | ||
@@ -467,0 +467,0 @@ public fitViewOnInit = defaultConfigValues.fitViewOnInit |
@@ -96,3 +96,3 @@ import { select, Selection } from 'd3-selection' | ||
if (this.config.disableZoom) this.disableZoom() | ||
this.setZoomLevel(this.config.initialZoomLevel) | ||
this.setZoomLevel(this.config.initialZoomLevel ?? 1) | ||
@@ -104,4 +104,2 @@ this.reglInstance = regl({ | ||
preserveDrawingBuffer: true, | ||
premultipliedAlpha: false, | ||
alpha: false, | ||
}, | ||
@@ -223,3 +221,3 @@ extensions: ['OES_texture_float', 'ANGLE_instanced_arrays'], | ||
public setData (nodes: N[], links: L[], runSimulation = true): void { | ||
const { fitViewOnInit, fitViewDelay, fitViewByNodesInRect } = this.config | ||
const { fitViewOnInit, fitViewDelay, fitViewByNodesInRect, initialZoomLevel } = this.config | ||
if (!nodes.length && !links.length) { | ||
@@ -235,3 +233,4 @@ this.destroyParticleSystem() | ||
this.graph.setData(nodes, links) | ||
if (this._isFirstDataAfterInit && fitViewOnInit) { | ||
// If `initialZoomLevel` is set, we don't need to fit the view | ||
if (this._isFirstDataAfterInit && fitViewOnInit && initialZoomLevel === undefined) { | ||
this._fitViewOnInitTimeoutID = window.setTimeout(() => { | ||
@@ -289,6 +288,11 @@ if (fitViewByNodesInRect) this.setZoomTransformByNodePositions(fitViewByNodesInRect, undefined, undefined, 0) | ||
public setZoomLevel (value: number, duration = 0): void { | ||
this.canvasD3Selection | ||
.transition() | ||
.duration(duration) | ||
.call(this.zoomInstance.behavior.scaleTo, value) | ||
if (duration === 0) { | ||
this.canvasD3Selection | ||
.call(this.zoomInstance.behavior.scaleTo, value) | ||
} else { | ||
this.canvasD3Selection | ||
.transition() | ||
.duration(duration) | ||
.call(this.zoomInstance.behavior.scaleTo, value) | ||
} | ||
} | ||
@@ -295,0 +299,0 @@ |
@@ -42,3 +42,2 @@ export const defaultNodeColor = '#b3b3b3' | ||
scaleNodesOnZoom: true, | ||
initialZoomLevel: 1, | ||
disableZoom: false, | ||
@@ -45,0 +44,0 @@ fitViewOnInit: true, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1782031
9046