Skip to content

Commit

Permalink
don't repaint with opacityProperty, see #198
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Feb 21, 2020
1 parent eb306f6 commit 992b5a6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions js/energy-skate-park/graphs/view/EnergyPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,21 @@ define( require => {
this.thermalEnergyDataSeries.addDataPoint( new PointStyledVector2( independentVariable, addedSample.thermalEnergy, pointStyle ) );
this.totalEnergyDataSeries.addDataPoint( new PointStyledVector2( independentVariable, addedSample.totalEnergy, pointStyle ) );

// add a listener that updates opacity with the SkaterSample Property, dispose it on removal
const opacityListener = opacity => {
pointStyle.opacity = opacity;
this.invalidateDataSeriesNodes();
};
addedSample.opacityProperty.link( opacityListener );

// don't repaint 4 canvases ANY opacityProperty changes for any skaterSample, seems very
// inneficient
// // add a listener that updates opacity with the SkaterSample Property, dispose it on removal
// const opacityListener = opacity => {
// console.log( 'here' );
//
// pointStyle.opacity = opacity;
// this.invalidateDataSeriesNodes();
// };
// addedSample.opacityProperty.link( opacityListener );

const removalListener = removedSample => {
if ( removedSample === addedSample ) {
removedSample.opacityProperty.unlink( opacityListener );
// removedSample.opacityProperty.unlink( opacityListener );
this.forEachDataSeries( dataSeries => dataSeries.removePointAtX( independentVariable ) );
model.skaterSamples.removeItemRemovedListener( removalListener );
}
Expand Down

0 comments on commit 992b5a6

Please sign in to comment.