From cbaaa7413ca91a0a2e06c6bfd751b243a9955026 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Wed, 13 May 2020 12:45:22 +0200 Subject: [PATCH] Fix smart annotation position for horizontal scroll --- app/assets/javascripts/sitewide/atwho_res.js.erb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/sitewide/atwho_res.js.erb b/app/assets/javascripts/sitewide/atwho_res.js.erb index 2433fbb63..b74f09884 100644 --- a/app/assets/javascripts/sitewide/atwho_res.js.erb +++ b/app/assets/javascripts/sitewide/atwho_res.js.erb @@ -381,8 +381,15 @@ var SmartAnnotation = (function() { function init() { $(field) .on("reposition.atwho", function(event, flag, query) { - if (query.$inputor.offset().left > $(window).width()) { - query.$el.find('.atwho-view').css('left', (flag.left + $(window).scrollLeft()) + 'px'); + let inputFieldLeft = query.$inputor.offset().left; + if (inputFieldLeft > $(window).width()) { + let leftPosition; + if (inputFieldLeft < flag.left + $(window).scrollLeft()) { + leftPosition = inputFieldLeft; + } else { + leftPosition = flag.left + $(window).scrollLeft(); + } + query.$el.find('.atwho-view').css('left', leftPosition + 'px'); } if ($('.repository-show').length) { query.$el.find('.atwho-view').css('top', flag.top + 'px');