7
7
'underscore' ,
8
8
'./abstract' ,
9
9
'Magento_Ui/js/lib/key-codes' ,
10
- 'mage/translate'
11
- ] , function ( _ , Abstract , keyCodes , $t ) {
10
+ 'mage/translate' ,
11
+ 'jquery'
12
+ ] , function ( _ , Abstract , keyCodes , $t , $ ) {
12
13
'use strict' ;
13
14
14
15
/**
@@ -239,9 +240,7 @@ define([
239
240
} ,
240
241
241
242
/**
242
- * get filtered value
243
- *
244
- * @returns {Array } filtered array
243
+ * Get filtered value*
245
244
*/
246
245
getValue : function ( ) {
247
246
var options = this . options ( ) ,
@@ -255,7 +254,7 @@ define([
255
254
} ,
256
255
257
256
/**
258
- * get selected element labels
257
+ * Get selected element labels
259
258
*
260
259
* @returns {Array } array labels
261
260
*/
@@ -301,16 +300,45 @@ define([
301
300
*
302
301
* @param {Object } data - object with data about this element
303
302
* @param {Number } index - element index
303
+ * @param {Object } event - mousemove event
304
+ */
305
+
306
+ onMousemove : function ( data , index , event ) {
307
+ var target = $ ( event . target ) ,
308
+ id ;
309
+
310
+ if ( this . isCursorPositionChange ( event ) ) {
311
+ return false ;
312
+ }
313
+
314
+ target . is ( 'li' ) ? id = target . index ( ) : id = target . parent ( 'li' ) . index ( ) ;
315
+ id !== this . hoverElIndex ( ) ? this . hoverElIndex ( id ) : false ;
316
+
317
+ this . setCursorPosition ( event ) ;
318
+ } ,
319
+
320
+ /**
321
+ * Set X and Y cursor position
322
+ *
323
+ * @param {Object } event - mousemove event
304
324
*/
305
- onHoveredIn : function ( data , index ) {
306
- this . hoverElIndex ( index ) ;
325
+ setCursorPosition : function ( event ) {
326
+ this . cursorPosition = {
327
+ x : event . pageX ,
328
+ y : event . pageY
329
+ } ;
307
330
} ,
308
331
309
332
/**
310
- * Remove hover to some list element and write element ID from variable
333
+ * Check previous and current cursor position
334
+ *
335
+ * @param {Object } event - mousemove event
336
+ * @returns {Boolean }
311
337
*/
312
- onHoveredOut : function ( ) {
313
- this . hoverElIndex ( null ) ;
338
+ isCursorPositionChange : function ( event ) {
339
+ return this . cursorPosition &&
340
+ this . cursorPosition . x === event . pageX &&
341
+ this . cursorPosition . y === event . pageY ;
314
342
} ,
315
343
316
344
/**
@@ -394,7 +422,7 @@ define([
394
422
var keyName = keyCodes [ event . keyCode ] ;
395
423
396
424
if ( this . isTabKey ( event ) ) {
397
- if ( ! this . filterOptionsFocus ( ) && this . listVisible ( ) && this . filterOptions ) {
425
+ if ( ! this . filterOptionsFocus ( ) && this . listVisible ( ) && this . filterOptions ) {
398
426
this . cacheUiSelect . blur ( ) ;
399
427
this . filterOptionsFocus ( true ) ;
400
428
this . cleanHoveredElement ( ) ;
0 commit comments