`mousemove` and triggering a custom event

Kamran Ahmed

In a mousemove event:

$(document).on('mousemove', function( e ){
    console.log( e.pageX );
    console.log( e.pageY );
});

as you can see, we can use pageX and pageY to get the x and y co-ordinates of mouse position. But, what I want is to trigger a custom event of mine on mousemove and would like to get these pageX and pageY values in that custom event of mine. To be more clear, what I would like to do is:

$(document).on('mousemove', function(){
    $(document).trigger('myevent');
});

$(document).on('myevent', function( e ){
    // console.log( e.pageX );
    // console.log( e.pageY );
});

Is there any way to access these pageX and pageY in myevent?

jAndy

.trigger() allows to pass additional data via its arguments. You can call

$(document).on('mousemove', function( event ){
    $(document).trigger('myevent', event);
});

Now you have access to the whole original event object within your custom event code.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Mousemove event after Onclick event

分類Dev

Event triggering on slide appearance

分類Dev

Stop Triggering Event on Page Load

分類Dev

Javascript "mousemove" event sometimes doesn't fire

分類Dev

jQuery: Finish dragging without triggering click event

分類Dev

React - Triggering click event on table row

分類Dev

Click event not triggering for every iteration of for loop

分類Dev

Triggering custom events in backbone.js

分類Dev

inotifywait triggering event twice while converting docx to PDF

分類Dev

React HOC DOM properties are triggering 'Unknown event handler property'

分類Dev

Attach click event to body via button click without immediately triggering it

分類Dev

Triggering an event in c# from c++ and declaring LPCWSTR

分類Dev

Custom event for countdown javascript

分類Dev

How to trigger Control.MouseMove event when maximized/un-maximized form in winforms C#

分類Dev

Custom event messages with NDIS driver

分類Dev

How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

分類Dev

How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

分類Dev

How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

分類Dev

How can I kill a child process without the child process 'exit' event triggering?

分類Dev

HTML5 video timeupdate event not triggering while focused on other tab in chrome

分類Dev

Is it possible to create and handle a custom Event in a Customized UserForm?

分類Dev

Common Event Listener for multiple instances of custom element

分類Dev

Pass Optional Event Handler to Custom Button

分類Dev

Update a custom field in Acumatica in the Row Persisted Event

分類Dev

Custom Error Message for Event Receiver in SharePoint 2010

分類Dev

keyListenner と mousemove

分類Dev

Select2 Could not bind event on clicking custom no results text

分類Dev

How to get jQuery to trigger a native custom event handler

分類Dev

Customize jQuery DataTable To Get Custom CheckBox Event Row Wise

Related 関連記事

  1. 1

    Mousemove event after Onclick event

  2. 2

    Event triggering on slide appearance

  3. 3

    Stop Triggering Event on Page Load

  4. 4

    Javascript "mousemove" event sometimes doesn't fire

  5. 5

    jQuery: Finish dragging without triggering click event

  6. 6

    React - Triggering click event on table row

  7. 7

    Click event not triggering for every iteration of for loop

  8. 8

    Triggering custom events in backbone.js

  9. 9

    inotifywait triggering event twice while converting docx to PDF

  10. 10

    React HOC DOM properties are triggering 'Unknown event handler property'

  11. 11

    Attach click event to body via button click without immediately triggering it

  12. 12

    Triggering an event in c# from c++ and declaring LPCWSTR

  13. 13

    Custom event for countdown javascript

  14. 14

    How to trigger Control.MouseMove event when maximized/un-maximized form in winforms C#

  15. 15

    Custom event messages with NDIS driver

  16. 16

    How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

  17. 17

    How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

  18. 18

    How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

  19. 19

    How can I kill a child process without the child process 'exit' event triggering?

  20. 20

    HTML5 video timeupdate event not triggering while focused on other tab in chrome

  21. 21

    Is it possible to create and handle a custom Event in a Customized UserForm?

  22. 22

    Common Event Listener for multiple instances of custom element

  23. 23

    Pass Optional Event Handler to Custom Button

  24. 24

    Update a custom field in Acumatica in the Row Persisted Event

  25. 25

    Custom Error Message for Event Receiver in SharePoint 2010

  26. 26

    keyListenner と mousemove

  27. 27

    Select2 Could not bind event on clicking custom no results text

  28. 28

    How to get jQuery to trigger a native custom event handler

  29. 29

    Customize jQuery DataTable To Get Custom CheckBox Event Row Wise

ホットタグ

アーカイブ