DEV: Move scrollToBottom action
This commit is contained in:
parent
fd9c23b2dc
commit
3a174ab765
|
@ -1,7 +1,21 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { headerOffset } from "discourse/lib/offset-calculator";
|
||||
|
||||
export default class TableOfContents extends Component {
|
||||
@action
|
||||
scrollToBottom(e) {
|
||||
e.preventDefault();
|
||||
const rect = document
|
||||
.querySelector(".d-toc-cooked")
|
||||
.getBoundingClientRect();
|
||||
|
||||
window.scrollTo({
|
||||
top: rect.bottom + window.scrollY - headerOffset() - 10,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
closeOverlay(e) {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -192,23 +192,6 @@ export default {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (e.target.closest("a")) {
|
||||
// link to first post bottom
|
||||
if (e.target.closest("a").classList.contains("scroll-to-bottom")) {
|
||||
const rect = document
|
||||
.querySelector(".d-toc-cooked")
|
||||
.getBoundingClientRect();
|
||||
|
||||
window.scrollTo({
|
||||
top: rect.bottom + window.scrollY - headerOffset() - 10,
|
||||
behavior: "smooth",
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!document.querySelector(".d-toc-wrapper.overlay")) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<div class="d-toc-main">
|
||||
<div class="d-toc-icons">
|
||||
<a
|
||||
href="#"
|
||||
href
|
||||
class="scroll-to-bottom"
|
||||
title={{i18n (theme-prefix "post_bottom_tooltip")}}
|
||||
{{on "click" this.scrollToBottom}}
|
||||
>
|
||||
{{d-icon "downward"}}
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue