Bug fix for scroll to end.

This commit is contained in:
Scott Idem
2025-09-19 16:50:14 -04:00
parent 5b7aa320e2
commit 79c0c90eae
2 changed files with 35 additions and 23 deletions

View File

@@ -74,6 +74,7 @@ let yTop = $state(0);
let yScroll = $state(0);
let yHeight = $state(0);
let scroll_x = $state(0);
let scroll_y = $state(0);
function parse_scroll() {
@@ -225,16 +226,6 @@ function scroll_container() {
class:opacity-0={yTop < 750}
class:ae_btn_warning_filled={yTop > 1500}
onclick={() => {
log_lvl = 1;
if (log_lvl) {
console.log(`Scroll to top button clicked. scroll_y: ${scroll_y} scrollTop: ${scroll_container().scrollTop}`, scroll_container());
// document.getElementById('ae_idaa')?.scrollTo(0, 0);
// document.documentElement?.scrollTo(0, 0);
// document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
// document.body.scrollTop = 0; // For Safari
}
console.log('Not Safari, using smooth scroll to top');
document.getElementById('ae_main_content')?.scrollTo({
top: 0,
behavior: 'smooth'
@@ -264,27 +255,18 @@ function scroll_container() {
class:opacity-0={yTop < 750}
class:ae_btn_warning_filled={yTop > 1500}
onclick={() => {
log_lvl = 1;
if (log_lvl) {
console.log(`Scroll to bottom button clicked. scroll_y: ${scroll_y} scrollTop: ${scroll_container().scrollTop}`, scroll_container());
// document.getElementById('ae_idaa')?.scrollTo(0, 0);
// document.documentElement?.scrollTo(0, 0);
// document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
// document.body.scrollTop = 0; // For Safari
}
console.log('Not Safari, using smooth scroll to bottom');
document.getElementById('ae_main_content')?.scrollTo({
top: scroll_y,
top: yScroll,
behavior: 'smooth'
});
window.parent.postMessage({'scroll_to': scroll_y}, "*"); // This should be
window.parent.postMessage({'scroll_to': scroll_y}, "*");
}}
title="Scroll to bottom"
>
<span class="fas fa-arrow-down"></span>
Scroll to Bottom
<!-- yTop={yTop} yScroll={yScroll} yHeight={yHeight} scroll_y={scroll_y} scrollTop={scroll_container().scrollTop} total={scroll_container().scrollTop + yHeight} -->
</button>
</div>

View File

@@ -307,6 +307,35 @@ function scroll_container() {
Scroll to Top
</button>
<!-- Scroll to the right button -->
<button
type="button"
class="
ae_btn_success_outlined
btn btn-sm btn-secondary
preset-tonal-surface
transition-all duration-500
"
class:ae_btn_warning_filled={xLeft + xWidth < xScroll - 750}
onclick={() => {
document.getElementById('ae_main_content')?.scrollTo({
left: 0,
behavior: 'smooth'
});
window.parent.postMessage({'scroll_to': scroll_x}, "*");
}}
title="Scroll to right"
>
<span class="fas fa-arrow-right"></span>
<!-- Scroll to Right
xLeft={xLeft} xScroll={xScroll} xWidth={xWidth} scroll_x={scroll_x} scrollLeft={scroll_container().scrollLeft}
total={xLeft + xWidth} -->
</button>
<!-- Scroll to bottom button -->
<button
type="button"
@@ -334,7 +363,7 @@ function scroll_container() {
console.log('Not Safari, using smooth scroll to bottom');
document.getElementById('ae_main_content')?.scrollTo({
top: scroll_y,
top: yScroll,
behavior: 'smooth'
});
@@ -344,6 +373,7 @@ function scroll_container() {
>
<span class="fas fa-arrow-down"></span>
Scroll to Bottom
<!-- yTop={yTop} yScroll={yScroll} yHeight={yHeight} scroll_y={scroll_y} scrollTop={scroll_container().scrollTop} total={scroll_container().scrollTop + yHeight} -->
</button>
</div>