Advertisement
gur111

Workaround for changing pin locations

Dec 25th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function relocateImg(){
  2.     // Get the pin object
  3.     let pin = document.images[4]; // TODO: You need to loop using different pins on this variable
  4.     // Get the page object
  5.     let img = document.getElementById("image_annotation");
  6.     // The original page width to calculate relative modifier
  7.     const pageOriginalWidth = 905;
  8.     // Get original pin location
  9.     const originalPX = pin.getAttribute("data-x");
  10.     const originalPY = pin.getAttribute("data-y");
  11.     // Calculate modifier
  12.     let mod = pageOriginalWidth/img.width;
  13.     // Set the location of the pin to be relative to the page's size
  14.     pin.style.left = originalPY/mod+"px"
  15.     pin.style.top = originalPX/mod+"px"
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement