mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 15:56:15 +01:00
Patch by Mizuki ISHIKAWA (user:ishikawa999). git-svn-id: https://svn.redmine.org/redmine/trunk@23752 e93f8b46-1217-0410-a6f0-8f06a7374b81
23 lines
526 B
JavaScript
23 lines
526 B
JavaScript
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();
|
|
}
|
|
}
|