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

Lower the intersection threshold to 25%

Kabiru Mwenja4f47f31f997d
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/infinite-scroll.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/infinite-scroll.controller.ts
index cc38cf63210..168d3f6ca80 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/infinite-scroll.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/infinite-scroll.controller.ts
@@ -62,15 +62,14 @@ export default class extends BaseController {
super.connect();
void this.initializeTurboRequestService();
- useIntersection(this, { threshold: 1.0 });
+ useIntersection(this, { threshold: 0.25 });
this.setupScrollPreservation();
}
disconnect() {
super.disconnect();
- this.abortController.abort();
- if (this.pageStreamHandler) this.pageStreamHandler = undefined;
+ this.tearDownScrollPreservation();
}
async appear() {
@@ -93,7 +92,7 @@ export default class extends BaseController {
}
}
- setupScrollPreservation() {
+ private setupScrollPreservation() {
if (!this.scrollableContainer || this.pageStreamHandler) return;
const { signal } = this.abortController;
@@ -118,6 +117,11 @@ export default class extends BaseController {
document.addEventListener('turbo:before-stream-render', this.pageStreamHandler as EventListener, { signal });
}
+ private tearDownScrollPreservation() {
+ this.abortController.abort();
+ if (this.pageStreamHandler) this.pageStreamHandler = undefined;
+ }
+
private fetchNextPageStream():Promise<{ html:string, headers:Headers }> {
const url = this.preparePageStreamsUrl();
return this.turboRequests.requestStream(url);
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/services/dom_helpers.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/services/dom_helpers.ts
index 9427231a758..b5cf04a90a1 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/services/dom_helpers.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/services/dom_helpers.ts
@@ -26,6 +26,31 @@
*
* See COPYRIGHT and LICENSE files for more details.
* ++
+*
+* Copyright (c) 37signals, LLC
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to deal in the Software without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to
+* permit persons to whom the Software is furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*
+* See also the original source:
+* * https://github.com/basecamp/once-campfire/blob/5c0526eaf7f83d129472a520fa673bfcb9c2f397/MIT-LICENSE
+* * https://github.com/basecamp/once-campfire/blob/5c0526eaf7f83d129472a520fa673bfcb9c2f397/app/javascript/helpers/dom_helpers.js#L44-L65
*/
export namespace DomHelpers {
@@ -83,9 +108,6 @@ export namespace DomHelpers {
* Without this, scroll preservation would be unreliable on mobile devices,
* especially during infinite scroll when users are actively scrolling up.
*
- * Credit: This technique was adapted from Basecamp's Campfire implementation
- * where they solved similar scroll position issues in their real-time chat.
- *
* @param {Element} container - The scrollable container to pause momentum on
*/
function pauseInertiaScroll(container:HTMLElement) {