Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gardenboi committed Nov 8, 2023
1 parent 97e1b47 commit a2de13e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
19 changes: 0 additions & 19 deletions src/scripts/modules/backToTop/backToTop.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/scripts/modules/backToTop/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export function backToTop() {
const button: HTMLDivElement = document.createElement( 'div' );
button.setAttribute( 'id', 'backtotop' );
const scrollToTop = () => {
window.scrollTo( {
top: 0,
behavior: 'smooth',
} );
};
button.onclick = scrollToTop;
document.body.appendChild( button );
}
6 changes: 6 additions & 0 deletions src/scripts/modules/scrollControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ function scrollCallback() {
}
}

if ( Ypos >= ( document.body.scrollHeight - window.innerHeight ) / 2 ) {
document.body.classList.remove( 'above-the-fold' );
} else {
document.body.classList.add( 'above-the-fold' );
}

if ( Ypos < 5 ) {
document.body.classList.add( 'top' );
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { modulrMasonryController } from './modules/masonry';
import { modulrSelectController } from './modules/select';
import { modulrGrid } from './modules/grid';
import { modulrScrollTo } from './modules/scroll/scroll';
import { backToTop } from './modules/backToTop/backToTop';
import { backToTop } from './modules/backToTop';

window.addEventListener( 'DOMContentLoaded', async () => {
/* enable scroll animations */
Expand Down

0 comments on commit a2de13e

Please sign in to comment.