Skip to content

Instantly share code, notes, and snippets.

@notepadwebdev
notepadwebdev / Belowfold plugin
Created July 4, 2012 08:39
Check if element is below the fold
$.belowfold = function(el) {
var fold = $(window).height() + $(window).scrollTop();
return fold <= $(el).offset().top;
};
@notepadwebdev
notepadwebdev / gist:4229950
Created December 7, 2012 01:18
Dee Dee in the kitchen
Fuckin...
I was in my kitchen right
checking to see if my T-shirt was dry right
and I just burst out laughing
cos on the label of my T-shirt
it said George
cos I got it fae Asda
and it was as if
every time I leave the kitchen
everything in the kitchen
@notepadwebdev
notepadwebdev / Front end dev chat
Created October 28, 2013 10:59
Interview notes for prospective front end dev role @epiphanysearch
/*
* Front end dev chat
*/
/* TOOLS */
- dev browser of choice. why?
- dev editor of choice. why?
- other tools?
/* HTML */
@notepadwebdev
notepadwebdev / background cover video
Last active August 29, 2015 13:57
background cover video
// background cover for position:fixed video
// aspectRatio = original aspect ratio of video
var ww = $(window).width(),
wh = $(window).height(),
wAR = ww / wh,
newW = (wAR < aspectRatio) ? 'auto' : ww,
newH = (wAR < aspectRatio) ? wh : 'auto',
mT = (wAR < aspectRatio) ? 0 : Math.round((el.height() - wh) / 2) * -1,
// Load the audio file for the loop
this.drumloop = new Pizzicato.Sound({
source: 'file',
options: {
path: '/assets/audio/drum-break-99bpm.wav',
loop: true
}
});
// Create the Low Pass Filter effect
@notepadwebdev
notepadwebdev / event-listeners.js
Last active November 21, 2016 19:14
Event listeners for speaker interaction
// Event Listeners
$('.speaker')
.on('touchstart mousedown', this.onTouchStart)
.on('touchmove mousemove', this.onTouchMove)
.on('touchend mouseup', this.onTouchEnd);
@notepadwebdev
notepadwebdev / event-handlers.js
Last active November 21, 2016 19:15
Event handlers for speaker interaction
// Event handlers
onTouchStart(e) {
e.preventDefault();
this.drumloop.play();
this.isPlaying = true;
}
onTouchEnd(e) {
this.drumloop.stop();
this.isPlaying = false;
@notepadwebdev
notepadwebdev / setLPF.js
Last active November 21, 2016 19:15
Set the low pass filter based on pageY position
// Set the low pass filter based on pageY position
// freq value will be between 0 and 10,000
setLPF(e) {
let freq = 10000 - ((this.getEvent(e).pageY / $(window).height()) * 10000);
this.LPF.frequency = freq;
}
@notepadwebdev
notepadwebdev / setPan.js
Last active November 21, 2016 19:16
Set the stereo panner position based on pageX position
// Set the stereo panner position based on pageX position
// pos value will be between -1 and 1
setPan(e) {
let pos = (((this.getEvent(e).pageX / $(window).width())*2)-1);
this.panner.pan = pos;
}
// Create Analyser
this.analyser = Pizzicato.context.createAnalyser();
this.analyser.fftSize = 1024;
this.bufferLength = this.analyser.frequencyBinCount;
this.dataArray = new Uint8Array(this.bufferLength);
this.LPF.connect(this.analyser);