Skip to content

Commit

Permalink
dispose instances of RichDragListener, #153
Browse files Browse the repository at this point in the history
(cherry picked from commit ccc67e1)
  • Loading branch information
pixelzoom committed Apr 9, 2024
1 parent a52138a commit 53bec41
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion js/common/view/PointToolNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ export default class PointToolNode extends Node {
} );

// interactivity
this.addInputListener( new PointToolDragListener( this, pointTool, modelViewTransform, graph ) );
const dragListener = new PointToolDragListener( this, pointTool, modelViewTransform, graph );
this.addInputListener( dragListener );

this.disposePointToolNode = () => {
updateMultilink.dispose();
bodyNode.dispose();
probeNode.dispose();
coordinatesProperty.dispose();
dragListener.dispose();
};
}

Expand Down
4 changes: 3 additions & 1 deletion js/common/view/manipulator/PointManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ export default class PointManipulator extends Manipulator {
};
pointProperty.link( lineObserver ); // unlink in dispose

this.addInputListener( new PointDragListener( this, pointProperty, otherPointProperties, xRange, yRange, modelViewTransform ) );
const dragListener = new PointDragListener( this, pointProperty, otherPointProperties, xRange, yRange, modelViewTransform );
this.addInputListener( dragListener );

this.disposePointManipulator = () => {
pointProperty.unlink( lineObserver );
dragListener.dispose();
};
}

Expand Down
4 changes: 3 additions & 1 deletion js/common/view/manipulator/SlopeManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export default class SlopeManipulator extends Manipulator {
};
lineProperty.link( lineObserver ); // unlink in dispose

this.addInputListener( new SlopeDragListener( this, lineProperty, riseRangeProperty, runRangeProperty, modelViewTransform ) );
const dragListener = new SlopeDragListener( this, lineProperty, riseRangeProperty, runRangeProperty, modelViewTransform );
this.addInputListener( dragListener );

this.disposeSlopeManipulator = () => {
lineProperty.unlink( lineObserver );
dragListener.dispose();
};
}

Expand Down
4 changes: 3 additions & 1 deletion js/common/view/manipulator/X1Y1Manipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ export default class X1Y1Manipulator extends Manipulator {
};
lineProperty.link( lineObserver ); // unlink in dispose

this.addInputListener( new X1Y1DragListener( this, lineProperty, x1RangeProperty, y1RangeProperty, modelViewTransform, constantSlope ) );
const dragListener = new X1Y1DragListener( this, lineProperty, x1RangeProperty, y1RangeProperty, modelViewTransform, constantSlope );
this.addInputListener( dragListener );

this.disposeX1Y1Manipulator = () => {
lineProperty.unlink( lineObserver );
dragListener.dispose();
};
}

Expand Down
4 changes: 3 additions & 1 deletion js/common/view/manipulator/X2Y2Manipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export default class X2Y2Manipulator extends Manipulator {
};
lineProperty.link( lineObserver ); // unlink in dispose

this.addInputListener( new X2Y2DragListener( this, lineProperty, x2RangeProperty, y2RangeProperty, modelViewTransform ) );
const dragListener = new X2Y2DragListener( this, lineProperty, x2RangeProperty, y2RangeProperty, modelViewTransform );
this.addInputListener( dragListener );

this.disposeX2Y2Manipulator = () => {
lineProperty.unlink( lineObserver );
dragListener.dispose();
};
}

Expand Down
4 changes: 3 additions & 1 deletion js/common/view/manipulator/YInterceptManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export default class YInterceptManipulator extends Manipulator {
};
lineProperty.link( lineObserver ); // unlink in dispose

this.addInputListener( new YInterceptDragListener( this, lineProperty, y1RangeProperty, modelViewTransform ) );
const dragListener = new YInterceptDragListener( this, lineProperty, y1RangeProperty, modelViewTransform );
this.addInputListener( dragListener );

this.disposeYInterceptManipulator = () => {
lineProperty.unlink( lineObserver );
dragListener.dispose();
};
}

Expand Down

0 comments on commit 53bec41

Please sign in to comment.