-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
167 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Pulsation | ||
@keyframes pulse { | ||
0% { | ||
transform: scale(0.3); | ||
} | ||
80%, | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
|
||
// // Pop-out effect | ||
// @keyframes seeMe { | ||
// 0% { | ||
// transform: scale(1); | ||
// } | ||
// 70% { | ||
// transform: scale(2); | ||
// } | ||
// 100% { | ||
// transform: scale(1); | ||
// } | ||
// } | ||
|
||
// .seeMe { | ||
// // transition: transform 300ms ease-in-out; | ||
// animation: seeMe 600ms cubic-bezier(0, 0.63, 0.49, 1.7); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
import { updateLocationHash } from './helper' | ||
|
||
/** | ||
* Scroll to a HTML element by target. | ||
* | ||
* @param {HTMLElement} target HTML element to scroll to | ||
* | ||
* @returns {number} Y position of target element | ||
*/ | ||
export function scrollTo(target) { | ||
const offset = 50 | ||
|
||
target.classList.remove('seeMe') | ||
const scrollY = window.scrollY || window.pageYOffset | ||
const headerHeight = document.getElementById('header').offsetHeight | ||
const elementPosition = target.getBoundingClientRect().top + scrollY | ||
const offsetPosition = Math.round(elementPosition - headerHeight - offset) | ||
|
||
window.addEventListener('scroll', function onScrollEvent() { | ||
if ( | ||
window.scrollY === offsetPosition || // reached element | ||
window.scrollY === document.body.scrollHeight - window.innerHeight || // reached document end | ||
window.scrollY === 0 // reached document start | ||
) { | ||
window.removeEventListener('scroll', onScrollEvent) | ||
target.classList.add('seeMe') | ||
updateLocationHash(target.id) | ||
} | ||
}) | ||
|
||
window.scrollTo({ | ||
top: offsetPosition, | ||
behavior: 'smooth', | ||
}) | ||
|
||
return offsetPosition | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters