Skip to content

Instantly share code, notes, and snippets.

View gist:fdf0461222af98660f9399fb4c49d340
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function (event) {
// On-page links
if (location.hostname == this.hostname) {
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
@MZOG
MZOG / js-add-class-after-scroll.js
Created Sep 25, 2019
JS add class after scroll
View js-add-class-after-scroll.js
let scrollpos = window.scrollY
const header = document.querySelector("nav")
const header_height = header.offsetHeight
const add_class = () => header.classList.add("fade-in")
const remove_class = () => header.classList.remove("fade-in")
window.addEventListener('scroll', function() {
scrollpos = window.scrollY;