pdf.js - jQuery mouseup event not firing on canvas displaying js pdf -


i asked this question while how plot co-ordinates on pdf displayed inline in browser.

@uselesscode helpful reply, pointing me towards pdf.js , supplying this live demo of how record co-ordinates of box dragged onto page.

i have been experimenting on page , have come across issues mouseup event on canvas element displaying pdf. on this example can see mousedown event fired along mousemove event, not mouseup event.

$(function () { "use strict"; var startx,     starty,     selectedboxes = [],     $selectionmarquee = $('#selectionmarquee'),     $allcords = $('#all-cords'),     positionbox = function ($box, coordinates) {         $box.css(             'top', coordinates.top         ).css(             'left', coordinates.left         ).css(             'height', coordinates.bottom - coordinates.top         ).css(             'width', coordinates.right - coordinates.left         );     },      comparenumbers = function (a, b) {         return - b;     },     getboxcoordinates = function (startx, starty, endx, endy) {         var x = [startx, endx].sort(comparenumbers),             y = [starty, endy].sort(comparenumbers);          return {             top: y[0],             left: x[0],             right: x[1],             bottom: y[1]         };     },     trackmouse = function (event) {         var position = getboxcoordinates(startx, starty, event.pagex, event.pagey);         console.log(position);         positionbox($selectionmarquee, position);     },     displaycoordinates = function () {         var msg = 'boxes far:\n';          selectedboxes.foreach(function (box) {             msg += '<li>(' + box.left + ', ' + box.top + ') - (' + (box.left + box.right) + ', ' + (box.top + box.bottom) + ')</li>';         });         $allcords.html(msg);     };   $('#the-canvas').on('mousedown', function (event) {     startx = event.pagex;     starty = event.pagey;     positionbox($selectionmarquee, getboxcoordinates(startx, starty, startx, starty));     $selectionmarquee.show();     $(this).on('mousemove', trackmouse); }).on('mouseup', function (event) {     var position,         $selectedbox;          $selectionmarquee.hide();          position = getboxcoordinates(startx, starty, event.pagex, event.pagey);          if (position.left !== position.right && position.top !== position.bottom) {             $selectedbox = $('<div class="selected-box"></div>');             $selectedbox.hide();             $('body').append($selectedbox);              positionbox($selectedbox, position);              $selectedbox.show();              selectedboxes.push(position);             displaycoordinates();             $(this).off('mousemove', trackmouse);         } }); }); 

i have played around , seem mouseup event firing when add absolute or fixed positioning canvas, mousemove event doesn't fire.

i'm sorry ask separate question have tried revive previous question no avail, , i'm stuck on project until can part working!


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -