-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The overlay is incorrectly positioned when the image for the markerarea is moved horizontally? #89
Comments
Since bootstrap "card" does
|
Aha, thank you for the quick answer! |
Puh, turns out that this just half of the issue I have in my codebase. I feel that there is a listener missing when the size of the MarkerArea changes? It gets correctly positioned once the browser window is resized? Untitled.movThis is the code I used (based on the previous code just with a button added): <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>All defaults demo</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>
<script src="https://unpkg.com/markerjs2/markerjs2.js"></script>
<script>
let toggled = false;
let markerArea;
function toggleCol() {
toggled = !toggled
if (toggled) {
document.getElementById("div-button").style.maxWidth = "300px"
} else {
document.getElementById("div-button").style.maxWidth = "60px"
}
// this does not work to properly reposition the MarkerArea
// markerArea.render();
// markerArea.show();
}
function showMarkerArea(target) {
markerArea = new markerjs2.MarkerArea(target);
markerArea.target = document.getElementById("card");
markerArea.addEventListener(
"render",
(event) => (target.src = event.dataUrl)
);
markerArea.show();
}
</script>
</head>
<body>
<div class="row">
<div class="col" id="div-button">
<div>
<button type="button" id="btn-toggle" class="btn btn-primary" onclick="toggleCol();">Change column
size</button>
</div>
</div>
<div class="col">
<div class="card" id="card">
<div class="card-body">
<img
src="https://picsum.photos/900"
onclick="showMarkerArea(this);"
alt="Test Image"/>
</div>
</div>
</div>
</div>
</body>
</html> |
Hmm... Yes, when it's neither window nor the image itself that is resizing then marker.js won't react. I'm not sure if there's a way to listen to all sizing changes across all parent elements but I will investigate. Additionally, there's some extra weirdness due to whatever styles bootstrap's "card" applies. Will look into that too. Overall, though, I'd recommend using "popup" mode in marker.js for marking up images in "fluid" environments. markerArea.settings.displayMode = 'popup'; |
I have this HTML file:
It displays like this initially:
After clicking on the image, I get this:
The overlay should appear exactly over the image, shouldn't it?
The text was updated successfully, but these errors were encountered: