Skip to content

Instantly share code, notes, and snippets.

View ffdead's full-sized avatar

David Lindkvist ffdead

View GitHub Profile
@ffdead
ffdead / glsl-noise.md
Last active June 13, 2022 08:35
Noise resources
@ffdead
ffdead / Image.js
Last active November 4, 2021 13:41
useCanvas hook in React component
const Image = () => {
const ref = useRef()
// add webgl component to global canvas while mounted
useCanvas(<WebGlImage image={ref} />)
return <img ref={ref} src={...} />
}
@ffdead
ffdead / gatsby-browser.js
Last active November 4, 2021 13:40
GlobalCanvas in layout
export const wrapRootElement = ({ element }) => (
<>
{element}
<GlobalCanvas/>
</>
)
@ffdead
ffdead / WistiaEmbed.js
Created November 2, 2020 09:43
React component for Wistia embed
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import classNames from 'classnames/bind'
import s from './WistiaEmbed.module.scss'
const cn = classNames.bind(s)
const WistiaEmbed = ({ id, play = false, style, options }) => {
// const el = useRef()
@ffdead
ffdead / if-resolution-example.scss
Created December 5, 2012 13:02
How to use if-resolution SASS mixin
footer {
// only include 1x size image for 'non-retina' screens
@include if-max-resolution(1.49) {
background-image: url('img/[email protected]');
}
// only include 2x size image for 'retina' screens
@include if-min-resolution(1.5) {
background-image: url('img/[email protected]');
background-size: 10.5625rem 1.5625rem;
}
@ffdead
ffdead / if-resolution.scss
Created December 5, 2012 12:32
SASS resolution media query mixin
/* @author 14islands.com
* SASS mixins for future proof resolution media query
*/
@mixin if-min-resolution($dppx) {
@include if-resolution(min, $dppx) {
@content;
}
}
@ffdead
ffdead / reflowFixedPositions.js
Created August 27, 2012 08:46
Solved position: fixed scrollTo() bug on iOS
/**
* Causes the browser to reflow all elements on the page.
* Fix for the iOS5 bug where fixed positioned elements are
* unavailable after programmatically calling window.scrollTo()
*
* @autor [email protected]
*/
reflowFixedPositions: function () {
document.documentElement.style.paddingRight = '1px';