Skip to content

Instantly share code, notes, and snippets.

View SergiyIlchyshyn's full-sized avatar
🏠
Working from home

Sergiy Ilchyshyn SergiyIlchyshyn

🏠
Working from home
View GitHub Profile
@SergiyIlchyshyn
SergiyIlchyshyn / README.md
Created March 21, 2020 16:36 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@SergiyIlchyshyn
SergiyIlchyshyn / change-class-on-scroll.js
Last active March 21, 2020 15:56
Show/Hide Element on Scroll / Vanilla JS
let scrollPos = 0;
const nav = document.querySelector('.site-nav');
function checkPosition() {
let windowY = window.scrollY;
if (windowY < scrollPos) {
// Scrolling UP
nav.classList.add('is-visible');
nav.classList.remove('is-hidden');
} else {
@SergiyIlchyshyn
SergiyIlchyshyn / change-class-on-scroll.html
Created March 21, 2020 15:38 — forked from ohiosveryown/change-class-on-scroll.html
Vanilla JS – change/add class based on scroll position.
// https://codepen.io/cmykw/pen/gemxJm
// layout
<nav/>
// style
<style>
body { min-height: 200vh; }
nav {
#root {
padding: 3rem;
text-align: center
}
#root h1 {
font-family: 'Press Start 2P', Consolas, monospace;
color: white;
}
<div id="root">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}