This file contains hidden or 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
| import React, {useEffect, useRef} from 'react'; | |
| const Component = () => { | |
| const isFirstRender = useRef(true); | |
| useEffect(() => { | |
| if (isFirstRender.current) { | |
| // this is the first render | |
| isFirstRender.current = false; | |
| return; |
This file contains hidden or 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
| " -------------------------------------------------------BASIC SETUP | |
| set nocompatible " be iMproved, required | |
| filetype off " required | |
| syntax on | |
| "--------------------------------------------------------VUNDLE | |
| " set the runtime path to include Vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim |
This file contains hidden or 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
| /* | |
| * Easing Functions - inspired from http://gizma.com/easing/ | |
| * only considering the t value for the range [0, 1] => [0, 1] | |
| */ | |
| EasingFunctions = { | |
| // no easing, no acceleration | |
| linear: function (t) { return t }, | |
| // accelerating from zero velocity | |
| easeInQuad: function (t) { return t*t }, | |
| // decelerating to zero velocity |
This file contains hidden or 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
| import { useState } from 'react'; | |
| const store = () => { | |
| // eslint-disable-next-line react-hooks/rules-of-hooks | |
| const [state, setState] = useState('test state'); | |
| const actions = action => { | |
| const { type, payload } = action; | |
| switch (type) { | |
| case 'setState': | |
| setState(payload); |
This file contains hidden or 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
| function elementInView(target) { | |
| // selects target div | |
| const targetDiv = document.querySelector(target); | |
| // gets target position from top of viewport | |
| const targetPosition = targetDiv.getBoundingClientRect(); | |
| switch (true) { | |
| case targetPosition.top > 1: | |
| console.log('hidden'); |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Smooth Scroll</title> | |
| <link rel="stylesheet" href="style.css"> | |
| </head> | |
| <body> |