Guest User

Untitled

a guest
Jun 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. // Why isn't the off()-function working below. When i click anywhere in the document it checks if the
  2. // target has a class called "drawing". If so, it activates the mousemove-event which fetches the
  3. // mouses current position. The idea is to remove that event when i relase the mouse but it doesn't
  4. // seem to work?
  5.  
  6. $(document).on({
  7. mousedown: function(e) {
  8. // If we are clicking on a drawing
  9. if($(e.target).hasClass('drawing')) {
  10. // Mouse move
  11. $(document).on('mousemove', function(e) {
  12. getMousePos(e);
  13. });
  14. }
  15. },
  16. mouseup: function(e) {
  17. // Mouse move
  18. $(document).off('mousemove');
  19. }
  20. });
Add Comment
Please, Sign In to add comment