mirror of
https://github.com/redmine/redmine.git
synced 2025-10-29 17:26:23 +01:00
Add a sticky issue header to issue page (#42684).
Patch by Mizuki ISHIKAWA (user:ishikawa999). git-svn-id: https://svn.redmine.org/redmine/trunk@23752 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
22
app/javascript/controllers/sticky_issue_header_controller.js
Normal file
22
app/javascript/controllers/sticky_issue_header_controller.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["original", "stickyHeader"];
|
||||
|
||||
connect() {
|
||||
if (!this.originalTarget || !this.stickyHeaderTarget) return;
|
||||
|
||||
this.observer = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
this.stickyHeaderTarget.classList.toggle("is-visible", !entry.isIntersecting);
|
||||
},
|
||||
{ threshold: 0 }
|
||||
);
|
||||
|
||||
this.observer.observe(this.originalTarget);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.observer?.disconnect();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user