Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Why isn't the off()-function working below. When i click anywhere in the document it checks if the
- // target has a class called "drawing". If so, it activates the mousemove-event which fetches the
- // mouses current position. The idea is to remove that event when i relase the mouse but it doesn't
- // seem to work?
- $(document).on({
- mousedown: function(e) {
- // If we are clicking on a drawing
- if($(e.target).hasClass('drawing')) {
- // Mouse move
- $(document).on('mousemove', function(e) {
- getMousePos(e);
- });
- }
- },
- mouseup: function(e) {
- // Mouse move
- $(document).off('mousemove');
- }
- });
Add Comment
Please, Sign In to add comment