gur111 icon

Pins locations workaround

gur111 | PRO | 12/25/17 11:18:15 AM UTC | 0 ⭐ | 515 👁️ | Never ⏰ | []
JavaScript |

650 B

|

None

|

0 👍

/

0 👎

function relocateImg(){
    let pins = document.getElementsByClassName("doc_pin_image")
    // Get the page object
    let img = document.getElementById("image_annotation");
    // The original page width to calculate relative modifier
    const pageOriginalWidth = 905;
    // Calculate modifier
    let mod = pageOriginalWidth/img.width;
    for(let i = 0; i<pins.length; i++){
        pin = pins[i];
        // Get original pin location
        const originalPX = pin.getAttribute("data-x");
        const originalPY = pin.getAttribute("data-y");
        // Set the location of the pin to be relative to the page's size
        pin.style.left = originalPY/mod+"px"
        pin.style.top = originalPX/mod+"px"
    }
}

Comments