From 6127ef9c72c11f7642f207faed054e8d76eb84c5 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 21 Jul 2022 20:54:28 +0300 Subject: [PATCH] list stick top fix --- client/src/views/record/list.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index fa6bf10bf6..87de787cf7 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -610,6 +610,7 @@ function (Dep, MassActionHelper, ExportHelper) { initStickedBar: function () { let $stickedBar = this.$stickedBar = this.$el.find('.sticked-bar'); let $middle = this.$el.find('> .list'); + let $window = $(window); let $scrollable = $window; @@ -617,11 +618,18 @@ function (Dep, MassActionHelper, ExportHelper) { this.$stickedBar = null; }); + let isModal = !!this.$el.closest('.modal-body').length; + let screenWidthXs = this.getThemeManager().getParam('screenWidthXs'); + let navbarHeight = this.getThemeManager().getParam('navbarHeight'); let getOffsetTop = (element) => { let offsetTop = 0; + let isSmallWindow = $(window.document).width() < screenWidthXs; + + let withHeader = !isSmallWindow && !isModal; + do { if (element.classList.contains('modal-body')) { break; @@ -634,25 +642,19 @@ function (Dep, MassActionHelper, ExportHelper) { element = element.offsetParent; } while (element); + if (withHeader) { + offsetTop -= navbarHeight; + } + return offsetTop; }; - let top; - if (this.$el.closest('.modal-body').length) { $scrollable = this.$el.closest('.modal-body'); - - top = 0; - } - else { - top = getOffsetTop(this.getParentView().$el.get(0)); - - if ($(window.document).width() < screenWidthXs) { - top = 0; - } } - top += this.$el.find('.list-buttons-container').height(); + let middleTop = getOffsetTop($middle.get(0)); + let buttonsTop = getOffsetTop(this.$el.find('.list-buttons-container').get(0)); $scrollable.off('scroll.list-' + this.cid); $scrollable.on('scroll.list-' + this.cid, () => controlSticking()); @@ -678,12 +680,11 @@ function (Dep, MassActionHelper, ExportHelper) { return; } - let middleTop = getOffsetTop($middle.get(0)); - - let stickTop = middleTop - top; - let edge = middleTop + $middle.outerHeight(true); let scrollTop = $scrollable.scrollTop(); + let stickTop = buttonsTop; + let edge = middleTop + $middle.outerHeight(true); + if (scrollTop >= edge) { $stickedBar.removeClass('hidden');