File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -193,10 +193,6 @@ the specific language governing permissions and limitations under the Apache Lic
193193 } ) ;
194194 }
195195
196- $document . on ( "mousemove" , function ( e ) {
197- lastMousePosition . x = e . pageX ;
198- lastMousePosition . y = e . pageY ;
199- } ) ;
200196
201197 /**
202198 * filters mouse events so an event is fired only if the mouse moved.
@@ -1343,6 +1339,12 @@ the specific language governing permissions and limitations under the Apache Lic
13431339
13441340 this . opening ( ) ;
13451341
1342+ // Only bind the document mousemove when the dropdown is visible
1343+ $document . on ( "mousemove.select2Event" , function ( e ) {
1344+ lastMousePosition . x = e . pageX ;
1345+ lastMousePosition . y = e . pageY ;
1346+ } ) ;
1347+
13461348 return true ;
13471349 } ,
13481350
@@ -1439,6 +1441,8 @@ the specific language governing permissions and limitations under the Apache Lic
14391441 this . container . removeClass ( "select2-dropdown-open" ) . removeClass ( "select2-container-active" ) ;
14401442 this . results . empty ( ) ;
14411443
1444+ // Now that the dropdown is closed, unbind the global document mousemove event
1445+ $document . off ( "mousemove.select2Event" ) ;
14421446
14431447 this . clearSearch ( ) ;
14441448 this . search . removeClass ( "select2-active" ) ;
You can’t perform that action at this time.
0 commit comments