Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function roundFloat(val) {
  2.         return Math.round(val * 100) / 100;
  3.     }
  4.  
  5.     function trackZoomCoordinates(previewId, markerId, inputIdX, inputIdY, markerSrc) {
  6.         var X, Y;
  7.  
  8.         $(previewId).mousemove(function(e) {
  9.             var offset = $(previewId).offset();
  10.             X = e.pageX - offset.left;
  11.             Y = e.pageY - offset.top;
  12.             $(previewId).attr("data-x", X);
  13.             $(previewId).attr("data-y", Y);
  14.         });
  15.  
  16.         $(previewId).on("click", function(e) {
  17.             $(markerId).attr("src", markerSrc).load(function() {
  18.                 $(markerId).css({
  19.                     "display": "block",
  20.                     "top": Number(Y) - $(markerId).height(),
  21.                     "left": Number(X) - ($(markerId).width() / 2)
  22.                 });
  23.             });
  24.  
  25.             $(inputIdX).val(roundFloat((X / $(previewId).width()) * 100));
  26.             $(inputIdY).val(roundFloat((Y / $(previewId).height()) * 100));
  27.         });
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement