mirror of
https://github.com/redmine/redmine.git
synced 2025-10-27 16:26:16 +01:00
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();
|
||
|
|
}
|
||
|
|
}
|