[Rt-commit] rt branch 5.0/fix-submenu-drift created. rt-5.0.2-258-g6bbcd0b847
BPS Git Server
git at git.bestpractical.com
Wed Jun 8 21:03:45 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/fix-submenu-drift has been created
at 6bbcd0b847df52dceec6abf55fe24b60c6fcb97d (commit)
- Log -----------------------------------------------------------------
commit 6bbcd0b847df52dceec6abf55fe24b60c6fcb97d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jun 9 04:16:15 2022 +0800
Fix the menu drift issue when clicking repositioned submenus
jquery.supposition.js is to tweak submenu positions if they overflow
screen in original positions. E.g. to lift the Scrips submenu from:
Admin
Users
Groups
Queues
...
Global Scrips
Conditions
Actions
Templates
...
Topics
to
Admin
Users Scrips
Groups Conditions
Queues Actions
... Templates
Global ...
Topics
Previously if you clicked one link in a repositioned submenu, the
submenu would be repositioned(again) back to the orignal position, which
we call a "drift" here. It is acutally a tricky precision issue, e.g.
var expandUp = (offsetTop + menuHeight > baseline);
if (expandUp) {
$u.css('margin-top', baseline - (menuHeight + offsetTop));
}
Even if "margin-top" is set correctly, "expandUp" could still be true
next time as "offsetTop + menuHeight - baseline" could be non-zero like
0.003, which would then set "margin-top" back to nearly 0, i.e. its
original position. This commit fixes this issue by allowing a bit
deviation.
diff --git a/share/static/js/jquery.supposition.js b/share/static/js/jquery.supposition.js
index a2e057102a..834db44904 100644
--- a/share/static/js/jquery.supposition.js
+++ b/share/static/js/jquery.supposition.js
@@ -34,11 +34,14 @@
this.each(function(){
var $u = $(this);
$u.css('display','block');
+ var deviation = 0.1; // make following conditions more tolerant to get rid of the precision issue.
+
var menuWidth = $u.width(),
parentWidth = $u.parents('ul').width(),
totalRight = $w.width() + _offset('x'),
menuRight = $u.offset().left + menuWidth;
- if (menuRight > totalRight) {
+
+ if (menuRight > totalRight + deviation) {
$u.css('margin-left', ($u.parents('ul').length === 1 ? totalRight - menuRight : -(menuWidth + parentWidth)) + 'px');
}
@@ -46,7 +49,7 @@
offsetTop = $u.offset().top,
menuHeight = $u.height(),
baseline = windowHeight + _offset('y');
- var expandUp = (offsetTop + menuHeight > baseline);
+ var expandUp = (offsetTop + menuHeight > baseline + deviation);
if (expandUp) {
$u.css('margin-top',baseline - (menuHeight + offsetTop));
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list