Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/interactive_physical_layout #4

Merged
merged 8 commits into from
Nov 22, 2016
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# System
.DS_Store

# IDE config
.idea

# Generated
/.jshintignore
/.jshintrc
Expand Down
41 changes: 29 additions & 12 deletions src/vizceral.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ import { isEqual, some } from 'lodash';
import React from 'react'; // eslint-disable-line import/no-unresolved, import/no-extraneous-dependencies
import VizceralGraph from 'vizceral';


function getPerformanceNow() {
let g = window;
if (g != null) {
let perf = g.performance;
if (perf != null) {
try {
let perfNow = perf.now();
if (typeof perfNow === "number") {
return perfNow;
}
} catch (e) {
}
}
}
return null;
}

/**
* ![](https://raw.githubusercontent.com/Netflix/vizceral/master/logo.png)
*
Expand All @@ -19,6 +37,7 @@ import VizceralGraph from 'vizceral';
* <Vizceral traffic={this.state.trafficData}
* view={this.state.currentView}
* showLabels={this.state.displayOptions.showLabels}
* physicsOptions={this.state.physicsOptions}
* filters={this.state.filters}
* graphsUpdated={this.graphsUpdated}
* viewChanged={this.viewChanged}
Expand Down Expand Up @@ -65,8 +84,8 @@ class Vizceral extends React.Component {
setTimeout(() => {
this.vizceral.setView(this.props.view || Vizceral.defaultProps.view, this.props.objectToHighlight);
this.vizceral.updateData(this.props.traffic);

this.vizceral.animate();
let perfNow = getPerformanceNow();
this.vizceral.animate(perfNow === null ? 0 : perfNow);
this.vizceral.updateBoundingRectCache();
}, 0);
}
Expand All @@ -84,11 +103,9 @@ class Vizceral extends React.Component {
if (!isEqual(nextProps.filters, this.props.filters)) {
this.vizceral.setFilters(nextProps.filters);
}

if (!isEqual(nextProps.showLabels, this.props.showLabels)) {
this.vizceral.setOptions({ showLabels: nextProps.showLabels });
}

if (!isEqual(nextProps.modes, this.props.modes)) {
this.vizceral.setModes(nextProps.modes);
}
Expand Down Expand Up @@ -200,18 +217,18 @@ Vizceral.defaultProps = {
connectionHighlighted: () => {},
definitions: {},
filters: [],
graphsUpdated: () => {},
graphsUpdated: () => undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change? These have default empty functions so they are just no-ops if the user does not provide listeners to things they do not care about.

Copy link
Contributor Author

@jbrekelmans jbrekelmans Nov 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the moment I thought all of those lambda expressions were creating functions that returned empty POJO's, but I learnt this is not the case. I'll undo them since I prefer the old syntax

match: '',
nodeFocused: () => {},
nodeHighlighted: () => {},
nodeUpdated: () => {},
nodeContextSizeChanged: () => {},
rendered: () => {},
matchesFound: () => {},
nodeFocused: () => undefined,
nodeHighlighted: () => undefined,
nodeUpdated: () => undefined,
nodeContextSizeChanged: () => undefined,
rendered: () => undefined,
matchesFound: () => undefined,
showLabels: true,
styles: {},
traffic: {},
viewChanged: () => {},
viewChanged: () => undefined,
view: []
};

Expand Down