Open SadmanYasar opened 1 month ago
I haven't looked deeply enough but what rubs me a bit wrong on the first glance is that you are manually/explicitly setting width/height in the state before opening it with marker.js Live:
const viewState: markerjs2.MarkerAreaState = {
width: target.width,
height: target.height,
markers: allMarkers
};
Not sure why you do that but this would mess up the internal scaling as it's done based on the width/height of the whole annotation in relation to the position and dimensions of individual markers.
I haven't looked deeply enough but what rubs me a bit wrong on the first glance is that you are manually/explicitly setting width/height in the state before opening it with marker.js Live:
const viewState: markerjs2.MarkerAreaState = { width: target.width, height: target.height, markers: allMarkers };
Not sure why you do that but this would mess up the internal scaling as it's done based on the width/height of the whole annotation in relation to the position and dimensions of individual markers.
Thanks! This was definitely the issue. It's fixed after I removed the width and height for the viewState.
I'm just facing one issue which is after resizing the image from mobile to desktop, the markerjs live doesn't scale the markers, only after markerArea is reinitialised it gets updated in the markerjs live. Is this because of the width set for the image? I tried setting width to full in the image but it doesn't seem to fix it.
I have a Nextjs app using Markerjs for annotating images. I set the width to 500px but on mobile view, its width is full. It works but due to resizing of the image, the canvas seems to resize but the markers are not scaling to the image. I am using a combination of both markerjs2 and markerjs live. So by default, it calls the showMarkers method attached below and when editing, it shows the markerArea. The edit is enabled using a state after clicking a row in a table. All the states are stored in a statemap so the markers are displayed on top of the original image instead of rendered image after adding a marker. Showing rendered image instead fixes this issue as its just showing an image, but I am looking for a way to make the markers responsive.
The code for showing markers:
The code for displaying the image:
I also using popup instead of inline but the marker positions are inconsistent. Would appreciate any guidance on this. TIA.