@@ -35,14 +35,23 @@ function Mouse() {
3535Mouse . prototype = Object . create ( EventDispatcher . prototype ) ;
3636Mouse . prototype . constructor = Mouse ;
3737
38+ /**
39+ * @return {Number } mouse x position
40+ */
3841Mouse . prototype . getPosX = function ( ) {
3942 return this . _x ;
4043} ;
4144
45+ /**
46+ * @return {Number } mouse y position
47+ */
4248Mouse . prototype . getPosY = function ( ) {
4349 return this . _y ;
4450} ;
4551
52+ /**
53+ * @return {Array } mouse position as [x, y]
54+ */
4655Mouse . prototype . getPos = function ( out ) {
4756 if ( out === undefined ) {
4857 return [ this . _x , this . _y ] ;
@@ -52,14 +61,23 @@ Mouse.prototype.getPos = function(out){
5261 return out ;
5362} ;
5463
64+ /**
65+ * @return {Number } previous mouse x position
66+ */
5567Mouse . prototype . getPrevPosX = function ( ) {
5668 return this . _prevX ;
5769} ;
5870
71+ /**
72+ * @return {Number } previous mouse y position
73+ */
5974Mouse . prototype . getPrevPosY = function ( ) {
6075 return this . _prevY ;
6176} ;
6277
78+ /**
79+ * @return {Array } previous mouse position as [x, y]
80+ */
6381Mouse . prototype . getPrevPos = function ( out ) {
6482 if ( out === undefined ) {
6583 return [ this . _prevX , this . _prevY ] ;
@@ -69,14 +87,23 @@ Mouse.prototype.getPrevPos = function(out){
6987 return out ;
7088} ;
7189
90+ /**
91+ * @return {Number } the difference between current and the last position on the x axis
92+ */
7293Mouse . prototype . getDeltaX = function ( ) {
7394 return this . _deltaX ;
7495} ;
7596
97+ /**
98+ * @return {Number } the difference between current and the last position on the y axis
99+ */
76100Mouse . prototype . getDeltaY = function ( ) {
77101 return this . _deltaY ;
78102} ;
79103
104+ /**
105+ * @return {Array } the difference between current and the last position as [x,y]
106+ */
80107Mouse . prototype . getDelta = function ( out ) {
81108 if ( out === undefined ) {
82109 return [ this . _deltaX , this . _deltaY ] ;
@@ -86,18 +113,54 @@ Mouse.prototype.getDelta = function(out){
86113 return out ;
87114} ;
88115
116+ /**
117+ * Fires MOUSE_DOWN event
118+ * @protected
119+ *
120+ * @param {Object } e - event data
121+ * @param {String } e.x - mouse x position
122+ * @param {Number } e.y - mouse y position
123+ * @param {Boolean } e.altKey - is alt key pressed?
124+ * @param {Boolean } e.shiftKey - is shift key pressed?
125+ * @param {Boolean } e.ctrlKey - is ctrl key pressed?
126+ * @param {Boolean } e.metaKey - is meta (apple/win) key pressed?
127+ */
89128Mouse . prototype . handleMouseDown = function ( e ) {
90129 this . _isDown = true ;
91130 e . mouse = this ;
92131 this . dispatchEvent ( new MouseEvent ( MouseEvent . MOUSE_DOWN , e ) ) ;
93132}
94133
134+ /**
135+ * Fires MOUSE_UP event
136+ * @protected
137+ *
138+ * @param {Object } e - event data
139+ * @param {String } e.x - mouse x position
140+ * @param {Number } e.y - mouse y position
141+ * @param {Boolean } e.altKey - is alt key pressed?
142+ * @param {Boolean } e.shiftKey - is shift key pressed?
143+ * @param {Boolean } e.ctrlKey - is ctrl key pressed?
144+ * @param {Boolean } e.metaKey - is meta (apple/win) key pressed?
145+ */
95146Mouse . prototype . handleMouseUp = function ( e ) {
96147 this . _isDown = false ;
97148 e . mouse = this ;
98149 this . dispatchEvent ( new MouseEvent ( MouseEvent . MOUSE_UP , e ) ) ;
99150}
100151
152+ /**
153+ * Fires MOUSE_MOVE event
154+ * @protected
155+ *
156+ * @param {Object } e - event data
157+ * @param {String } e.x - mouse x position
158+ * @param {Number } e.y - mouse y position
159+ * @param {Boolean } e.altKey - is alt key pressed?
160+ * @param {Boolean } e.shiftKey - is shift key pressed?
161+ * @param {Boolean } e.ctrlKey - is ctrl key pressed?
162+ * @param {Boolean } e.metaKey - is meta (apple/win) key pressed?
163+ */
101164Mouse . prototype . handleMouseMove = function ( e ) {
102165 this . _prevX = this . _x ;
103166 this . _prevY = this . _y ;
@@ -117,6 +180,18 @@ Mouse.prototype.handleMouseMove = function(e) {
117180 }
118181}
119182
183+ /**
184+ * Fires MOUSE_SCROLL event
185+ * @protected
186+ *
187+ * @param {Object } e - event data
188+ * @param {String } e.dx - amount of scroll in x direction
189+ * @param {Number } e.dy - amount of scroll in y direction
190+ * @param {Boolean } e.altKey - is alt key pressed?
191+ * @param {Boolean } e.shiftKey - is shift key pressed?
192+ * @param {Boolean } e.ctrlKey - is ctrl key pressed?
193+ * @param {Boolean } e.metaKey - is meta (apple/win) key pressed?
194+ */
120195Mouse . prototype . handleMouseScroll = function ( e ) {
121196 e . mouse = this ;
122197 this . dispatchEvent ( new MouseEvent ( MouseEvent . MOUSE_SCROLL , e ) ) ;
0 commit comments