Bug 38899: Remove code duplication
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
56eb4a6850
commit
b44c08eb4f
|
|
@ -75,17 +75,21 @@ function togglePanel(node) {
|
|||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
//check if sticky element is stuck, if so add floating class
|
||||
if ($(".sticky").length) {
|
||||
function apply_sticky(nodes) {
|
||||
if (nodes) {
|
||||
const observer = new IntersectionObserver(
|
||||
([e]) =>
|
||||
e.target.classList.toggle("floating", e.intersectionRatio < 1),
|
||||
{ threshold: [1] }
|
||||
);
|
||||
|
||||
observer.observe(document.querySelector(".sticky"));
|
||||
observer.observe(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
//check if sticky element is stuck, if so add floating class
|
||||
apply_sticky(document.querySelector(".sticky"));
|
||||
|
||||
//check for a hash before setting focus
|
||||
let hash = window.location.hash;
|
||||
|
|
|
|||
|
|
@ -22,17 +22,10 @@ export default {
|
|||
observer: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
stickyToolbar([e]) {
|
||||
e.target.classList.toggle("floating", e.intersectionRatio < 1);
|
||||
},
|
||||
},
|
||||
methods: {},
|
||||
mounted() {
|
||||
if (this.sticky) {
|
||||
this.observer = new IntersectionObserver(this.stickyToolbar, {
|
||||
threshold: [1],
|
||||
});
|
||||
this.observer.observe(this.$refs.toolbar);
|
||||
apply_sticky(this.$refs.toolbar);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue