Skip to content

Instantly share code, notes, and snippets.

View iamchristough's full-sized avatar

Chris Tough iamchristough

View GitHub Profile
@iamchristough
iamchristough / styles
Created November 6, 2020 15:05
yLJxVaV
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.min.css" rel="stylesheet" />
@iamchristough
iamchristough / hero-video-shape-timeline-tween.markdown
Created November 5, 2020 10:33
Hero Video Shape Timeline Tween
@iamchristough
iamchristough / hideCursor.js
Created May 11, 2020 11:23
Hide Cursor on idle
(function() {
var mouseTimer = null, cursorVisible = true;
function disappearCursor() {
mouseTimer = null;
document.body.style.cursor = "none";
cursorVisible = false;
}
document.onmousemove = function() {
@iamchristough
iamchristough / animatedScrollTo.js
Created April 1, 2020 12:03 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
let renderer, camera, controls, scene,
width = window.innerWidth,
height = window.innerHeight;
init();
animate();
render();
function init() {
// RENDERER
@iamchristough
iamchristough / svg-icon-component.js
Created May 24, 2019 10:07
svg-icon-component.js
import React, { Component } from 'react'
import cx from 'classnames'
import PropTypes from 'prop-types'
import Instagram from '../../../static/images/instagram.svg'
import Story from '../../../static/images/story.svg'
import Facebook from '../../../static/images/facebook.svg'
import Twitter from '../../../static/images/twitter.svg'
import Snapchat from '../../../static/images/snapchat.svg'
import Youtube from '../../../static/images/youtube.svg'
import Blog from '../../../static/images/blog.svg'
"browserify": {
"transform": [["babelify", { "presets": ["es2015", "stage-0"] }]]
},
@iamchristough
iamchristough / buffer-loader.js
Created March 13, 2019 14:12
Buffer load Media files
function BufferLoader(context, urlList, callback) {
this.context = context;
this.urlList = urlList;
this.onload = callback;
this.bufferList = new Array();
this.loadCount = 0;
}
BufferLoader.prototype.loadBuffer = function(url, index) {
var request = new XMLHttpRequest();
@iamchristough
iamchristough / randomHex.js
Created February 14, 2019 12:07
Generate a random hex code
const randomHexColorCode = () => {
let n = (Math.random() * 0xfffff * 1000000).toString(16);
return '#' + n.slice(0, 6);
};
@iamchristough
iamchristough / mapElements.js
Last active February 14, 2019 10:50
Map elements and elements default positions to an array
const imgs = [...document.querySelectorAll('.content__img')];
const imgsTotal = imgs.length;
let imgTranslations = [...new Array(imgsTotal)].map(() => ({x: 0, y: 0}));