notes: fix note mispositioning when image is blacklisted.

If the image is blacklisted on initial page load then unblacklisted
after the image is loaded, then the notes will be mispositioned at the
bottom of the image. This is because we relied on $image.height() to
calculate the note position, but the image height is zero when the image
is hidden.

Potential fix for #4370.
This commit is contained in:
evazion
2020-03-28 14:56:38 -05:00
parent 5d12081e58
commit 71e1d7c2a5

View File

@@ -379,11 +379,12 @@ let Note = {
scale: function($note_box) {
var $image = $("#image");
var ratio = $image.width() / parseFloat($image.data("original-width"));
var x_percent = 100 * ratio * ($note_box.data('x') / $image.width());
var y_percent = 100 * ratio * ($note_box.data('y') / $image.height());
var height_percent = 100 * ratio * ($note_box.data('height') / $image.height());
var width_percent = 100 * ratio * ($note_box.data('width') / $image.width());
var original_width = $image.data("original-width");
var original_height = $image.data("original-height");
var x_percent = 100 * ($note_box.data('x') / original_width);
var y_percent = 100 * ($note_box.data('y') / original_height);
var height_percent = 100 * ($note_box.data('height') / original_height);
var width_percent = 100 * ($note_box.data('width') / original_width);
$note_box.css({
top: y_percent + '%',
left: x_percent + '%',