You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The draw/signature form functionality added in #8308 included support for "annotating" an image. Basically you upload an image into the form and then you can draw/annotate the image and save the updated file as a report attachment.
Unfortunately, if the annotation question is on the first page of the form, when the image is initially loaded, it actually shows up in the canvas zoomed too far out (instead of being properly fitted within the canvas:
Expected
Actual
To Reproduce
Use the draw_widget form and upload an image into the "Annotate image widget" question.
See that the image is zoomed out.
Use the reload button to clear the image
Upload the image into the question again
See that it is zoomed as expected
Expected behavior
The image should be loaded into the canvas at the right size the first time it is loaded.
Additional context
After doing some debugging, it appears to be a problem with how we only display the loading indicator while initializing the form. This means that the canvas.offsetWidth property is 0 until we finish initializing the for (and its widgets). Then we hide the loading indicator and display the form.
This is a problem because when the draw widget is enabled it tries to initialize the size of the canvas based on the offsetWidth/height. This, of course, does not behave as expected since the offsetWidth is still 0. The result is that the various downstream calculations in fromObjectURL do not work properly and the result is a zoomed out image.
This problem behavior does not happen if the annotation question is not on the first page. This is because the _resizeCanvas function is re-triggered when changing to a new page. At that point the loading screen is gone and canvas.offsetWidth is valued.
I am going to see if I can cook up a fix for this as part of enketo/enketo#1323, but it might require custom handling in cht-core...
The text was updated successfully, but these errors were encountered:
Describe the bug
The draw/signature form functionality added in #8308 included support for "annotating" an image. Basically you upload an image into the form and then you can draw/annotate the image and save the updated file as a report attachment.
Unfortunately, if the annotation question is on the first page of the form, when the image is initially loaded, it actually shows up in the canvas zoomed too far out (instead of being properly fitted within the canvas:
To Reproduce
Expected behavior
The image should be loaded into the canvas at the right size the first time it is loaded.
Additional context
After doing some debugging, it appears to be a problem with how we only display the loading indicator while initializing the form. This means that the
canvas.offsetWidth
property is0
until we finish initializing the for (and its widgets). Then we hide the loading indicator and display the form.This is a problem because when the draw widget is enabled it tries to initialize the size of the canvas based on the
offsetWidth/height
. This, of course, does not behave as expected since theoffsetWidth
is still0
. The result is that the various downstream calculations infromObjectURL
do not work properly and the result is a zoomed out image.This problem behavior does not happen if the annotation question is not on the first page. This is because the
_resizeCanvas
function is re-triggered when changing to a new page. At that point the loading screen is gone andcanvas.offsetWidth
is valued.I am going to see if I can cook up a fix for this as part of enketo/enketo#1323, but it might require custom handling in cht-core...
The text was updated successfully, but these errors were encountered: