11import Element from '../core/core.element' ;
22import { drawPoint } from '../helpers/helpers.canvas' ;
33
4+ function inRange ( el , pos , axis , useFinalPosition ) {
5+ const options = el . options ;
6+ const { [ axis ] : value } = el . getProps ( [ axis ] , useFinalPosition ) ;
7+
8+ return ( Math . abs ( pos - value ) < options . radius + options . hitRadius ) ;
9+ }
10+
411export default class PointElement extends Element {
512
613 constructor ( cfg ) {
@@ -22,16 +29,11 @@ export default class PointElement extends Element {
2229 }
2330
2431 inXRange ( mouseX , useFinalPosition ) {
25- const options = this . options ;
26- const { x} = this . getProps ( [ 'x' ] , useFinalPosition ) ;
27-
28- return ( Math . abs ( mouseX - x ) < options . radius + options . hitRadius ) ;
32+ return inRange ( this , mouseX , 'x' , useFinalPosition ) ;
2933 }
3034
3135 inYRange ( mouseY , useFinalPosition ) {
32- const options = this . options ;
33- const { y} = this . getProps ( [ 'x' ] , useFinalPosition ) ;
34- return ( Math . abs ( mouseY - y ) < options . radius + options . hitRadius ) ;
36+ return inRange ( this , mouseY , 'y' , useFinalPosition ) ;
3537 }
3638
3739 getCenterPoint ( useFinalPosition ) {
0 commit comments