Advertisement
gur111

Pins locations workaround

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