Skip to content

Commit

Permalink
Simplified ReadingIndicator and remove exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Apr 11, 2024
1 parent 2cdf5ca commit 86fd9a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@inject IJSRuntime JSRuntime
@implements IAsyncDisposable

<div class="progress-container" @ref="progressContainer">
<svg class="progress-circle" viewBox="0 0 36 36">
Expand All @@ -22,9 +21,4 @@
await JSRuntime.InvokeVoidAsync("initCircularReadingProgress", ContainerCssSelector, progressContainer);
}
}

public async ValueTask DisposeAsync()
{
await JSRuntime.InvokeVoidAsync("destroyCircularReadingProgress");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ function hideProgressIndicator(progressContainer) {
}, 500);
}

function onScroll(onScroll) {
if (!rafId) {
rafId = requestAnimationFrame(onScroll);
}
}

window.initCircularReadingProgress = (parentContainer, progressContainer) => {
if (window.circularProgressScrollListenerAdded) {
return;
}

const progressBar = document.getElementById('progressBar');

const onScroll = () => {
Expand All @@ -50,11 +48,5 @@ window.initCircularReadingProgress = (parentContainer, progressContainer) => {
rafId = null;
};

window.addEventListener('scroll', onScroll) ;
window.addEventListener('scroll', onScroll);
};

window.destroyCircularReadingProgress = () => {
window.removeEventListener('scroll', onScroll);
clearTimeout(progressTimeout);
cancelAnimationFrame(rafId);
}

0 comments on commit 86fd9a8

Please sign in to comment.