API Docs for:
Show:

File: app/components/nf-crosshair.js

  1. import Ember from 'ember';
  2. import HasGraphParent from 'ember-nf-graph/mixins/graph-has-graph-parent';
  3.  
  4. /**
  5. A component that adds a "crosshair" to an `nf-graph` that follows the mouse
  6. while it's hovering over the graph content.
  7. @namespace components
  8. @class nf-crosshair
  9. @extends Ember.Component
  10. @uses mixins.graph-has-graph-parent
  11. */
  12. export default Ember.Component.extend(HasGraphParent, {
  13. tagName: 'g',
  14.  
  15. classNames: ['nf-crosshair'],
  16.  
  17. /**
  18. The height of the crosshair in pixels
  19. @property height
  20. @type Number
  21. @readonly
  22. */
  23. height: Ember.computed.alias('graph.graphHeight'),
  24.  
  25. /**
  26. The width of the crosshair in pixels
  27. @property width
  28. @type Number
  29. @readonly
  30. */
  31. width: Ember.computed.alias('graph.graphWidth'),
  32.  
  33. /**
  34. The x position of the crosshairs
  35. @property x
  36. @type Number
  37. @default 0
  38. */
  39. x: 0,
  40.  
  41. /**
  42. The y position of the crosshairs
  43. @property y
  44. @type Number
  45. @default 0
  46. */
  47. y: 0,
  48.  
  49. /**
  50. The visibility of the component
  51. @property isVisible
  52. @type Boolean
  53. @default false
  54. */
  55. isVisible: false,
  56.  
  57. didContentHoverChange: function(e) {
  58. this.set('isVisible', true);
  59. this.set('x', e.get('mouseX'));
  60. this.set('y', e.get('mouseY'));
  61. },
  62.  
  63. didContentHoverEnd: function() {
  64. this.set('isVisible', false);
  65. },
  66.  
  67. _setupBindings: Ember.observer('graph.content', function() {
  68. var content = this.get('graph.content');
  69. if(content) {
  70. content.on('didHoverChange', this, this.didContentHoverChange);
  71. content.on('didHoverEnd', this, this.didContentHoverEnd);
  72. }
  73. }),
  74. });