@@ -22,11 +22,12 @@ import Konva from 'konva/lib/Core';
2222 * @param {Boolean } enableEditing
2323 */
2424
25- function PointsLayer ( peaks , view , enableEditing ) {
25+ function PointsLayer ( peaks , view , enableEditing , filterPoints ) {
2626 this . _peaks = peaks ;
2727 this . _view = view ;
2828 this . _enableEditing = enableEditing ;
2929 this . _pointMarkers = { } ;
30+ this . _filterPoints = filterPoints ;
3031 this . _layer = new Konva . Layer ( ) ;
3132
3233 this . _onPointsDrag = this . _onPointsDrag . bind ( this ) ;
@@ -38,6 +39,7 @@ function PointsLayer(peaks, view, enableEditing) {
3839 this . _onPointMarkerMouseEnter = this . _onPointMarkerMouseEnter . bind ( this ) ;
3940 this . _onPointMarkerMouseLeave = this . _onPointMarkerMouseLeave . bind ( this ) ;
4041
42+ this . _isPointVisible = this . _isPointVisible . bind ( this ) ;
4143 this . _onPointsUpdate = this . _onPointsUpdate . bind ( this ) ;
4244 this . _onPointsAdd = this . _onPointsAdd . bind ( this ) ;
4345 this . _onPointsRemove = this . _onPointsRemove . bind ( this ) ;
@@ -79,12 +81,17 @@ PointsLayer.prototype.formatTime = function(time) {
7981 return this . _view . formatTime ( time ) ;
8082} ;
8183
84+ PointsLayer . prototype . _isPointVisible = function ( point , startTime , endTime ) {
85+ const isInFrame = point . isVisible ( startTime , endTime ) ;
86+
87+ return isInFrame && ( ! this . _filterPoints || this . _filterPoints ( point ) ) ;
88+ } ;
89+
8290PointsLayer . prototype . _onPointsUpdate = function ( point , options ) {
91+ const pointMarker = this . getPointMarker ( point ) ;
8392 const frameStartTime = this . _view . getStartTime ( ) ;
8493 const frameEndTime = this . _view . getEndTime ( ) ;
85-
86- const pointMarker = this . getPointMarker ( point ) ;
87- const isVisible = point . isVisible ( frameStartTime , frameEndTime ) ;
94+ const isVisible = this . _isPointVisible ( point , frameStartTime , frameEndTime ) ;
8895
8996 if ( pointMarker && ! isVisible ) {
9097 // Remove point marker that is no longer visible.
@@ -115,7 +122,9 @@ PointsLayer.prototype._onPointsAdd = function(event) {
115122 const frameEndTime = self . _view . getEndTime ( ) ;
116123
117124 event . points . forEach ( function ( point ) {
118- if ( point . isVisible ( frameStartTime , frameEndTime ) ) {
125+ const isVisible = self . _isPointVisible ( point , frameStartTime , frameEndTime ) ;
126+
127+ if ( isVisible ) {
119128 self . _updatePoint ( point ) ;
120129 }
121130 } ) ;
@@ -331,7 +340,7 @@ PointsLayer.prototype._removeInvisiblePoints = function(startTime, endTime) {
331340 if ( objectHasProperty ( this . _pointMarkers , pointPid ) ) {
332341 const point = this . _pointMarkers [ pointPid ] . getPoint ( ) ;
333342
334- if ( ! point . isVisible ( startTime , endTime ) ) {
343+ if ( ! this . _isPointVisible ( point , startTime , endTime ) ) {
335344 this . _removePoint ( point ) ;
336345 }
337346 }
0 commit comments