Skip to content

Commit

Permalink
Revert "Smooth scrolling is back!"
Browse files Browse the repository at this point in the history
Wasn't working 100% and I need to fix scrolling in general dotnet/aspnetcore#53863

This reverts commit 9b92b20.
  • Loading branch information
danielchalmers committed Feb 7, 2024
1 parent 9b92b20 commit 85e90c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
async Task ScrollToTop()
{
logger.LogDebug("Scrolling to top");
await JSRuntime.InvokeVoidAsync("scrollToTopOfPage");
await JSRuntime.InvokeVoidAsync("scrollToAbsoluteTop");
}

async Task ScrollToGroup(string key)
Expand Down
7 changes: 3 additions & 4 deletions JournalApp/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
<script src="_content/MudBlazor/MudBlazor.min.js"></script>

<script>
window.scrollToTopOfPage = () => {
document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' })
window.scrollToAbsoluteTop = () => {
document.scrollingElement.scrollTop = 0
}

window.scrollToTopOfNestedElement = (ancestorSelector, descendantSelector) => {
var elementTop = document.querySelector(descendantSelector).offsetTop - document.querySelector(ancestorSelector).offsetTop;
document.scrollingElement.scrollTo({ top: elementTop, behavior: 'smooth' })
document.scrollingElement.scrollTop = document.querySelector(descendantSelector).offsetTop - document.querySelector(ancestorSelector).offsetTop
}
</script>

Expand Down

0 comments on commit 85e90c5

Please sign in to comment.