Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Bugfixes and performance enhanced

Inga Maib09af2be9a4a
diff --git a/frontend/src/app/globals/global-listeners.ts b/frontend/src/app/globals/global-listeners.ts
index 6d9776dbcbb..14b12b2b965 100644
--- a/frontend/src/app/globals/global-listeners.ts
+++ b/frontend/src/app/globals/global-listeners.ts
@@ -30,6 +30,7 @@ import {performAnchorHijacking} from "./global-listeners/link-hijacking";
import {augmentedDatePicker} from "./global-listeners/augmented-date-picker";
import {refreshOnFormChanges} from 'core-app/globals/global-listeners/refresh-on-form-changes';
import {registerRequestForConfirmation} from "core-app/globals/global-listeners/request-for-confirmation";
+import {DeviceService} from "core-app/modules/common/browser/device.service";
import {scrollHeaderOnMobile} from "core-app/globals/global-listeners/top-menu-scroll";
/**
@@ -96,8 +97,11 @@ import {scrollHeaderOnMobile} from "core-app/globals/global-listeners/top-menu-s
// to show the password confirmation dialog
registerRequestForConfirmation($);
+ const deviceService:DeviceService = new DeviceService();
// Register scroll handler on mobile header
- scrollHeaderOnMobile(jQuery('#content-wrapper'));
+ if (deviceService.isMobile) {
+ scrollHeaderOnMobile(jQuery('#content-wrapper'));
+ }
});
}(jQuery));
diff --git a/frontend/src/app/globals/global-listeners/top-menu-scroll.ts b/frontend/src/app/globals/global-listeners/top-menu-scroll.ts
index 81f8d46f626..278e1f065fd 100644
--- a/frontend/src/app/globals/global-listeners/top-menu-scroll.ts
+++ b/frontend/src/app/globals/global-listeners/top-menu-scroll.ts
@@ -27,27 +27,31 @@
// ++
-import {DeviceService} from "core-app/modules/common/browser/device.service";
-
+// Scroll header on mobile in and out when user scrolls the container
export function scrollHeaderOnMobile(elem:JQuery) {
- const deviceService:DeviceService = new DeviceService();
- const headerHeight = '55px';
- let prevScrollPos = elem.scrollTop();
+ const headerHeight = 55;
+ let prevScrollPos = elem.scrollTop()!;
- elem.on('scroll', (event) => {
- // Only on mobile screen sizes and if sidebar is not opened or search bar is opened
- if (!deviceService.isMobile ||
- !(jQuery('#main').hasClass('hidden-navigation')) ||
- jQuery('#top-menu').hasClass('-global-search-expanded')) {
+ elem.on('scroll', function() {
+ // Condition needed for safari browser to avoid negative positions
+ let currentScrollPos = elem.scrollTop()! < 0 ? 0 : elem.scrollTop()!;
+ // Only if sidebar is not opened or search bar is opened
+ if (!(jQuery('#main').hasClass('hidden-navigation')) ||
+ jQuery('#top-menu').hasClass('-global-search-expanded') ||
+ Math.abs(currentScrollPos - prevScrollPos) <= headerHeight) { // to avoid flickering at the end of the page
return;
}
- let currentScrollPos = elem.scrollTop();
- if ((prevScrollPos && currentScrollPos && prevScrollPos >= currentScrollPos) || currentScrollPos === 0) {
- jQuery('#top-menu').css({'margin-top':'0', transition:'margin-top .4s'});
- } else {
- jQuery('#top-menu').css({'margin-top':'-' + headerHeight, transition:'margin-top .4s'});
+ let marginTop:number = -headerHeight;
+ if (prevScrollPos !== undefined && currentScrollPos !== undefined && (prevScrollPos > currentScrollPos)) {
+ marginTop = 0;
}
+ toggleTopMenu(marginTop);
prevScrollPos = currentScrollPos;
});
}
+
+// Slide top menu in or out of viewport
+function toggleTopMenu(marginTop:number) {
+ jQuery('#top-menu').css({'margin-top': marginTop + 'px', transition:'margin-top .4s'});
+}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts b/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
index 2369af3193e..c2adefd6e96 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
@@ -132,8 +132,10 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
this.cdRef.detectChanges();
- // Scroll header on mobile in and out when user scrolls the container
- scrollHeaderOnMobile(jQuery('.work-packages--card-view-container'));
+ // Register scroll handler on mobile header
+ if (this.deviceService.isMobile) {
+ scrollHeaderOnMobile(jQuery('.work-packages--card-view-container'));
+ }
});
}