Skip to content

Instantly share code, notes, and snippets.

@narrowdesign
narrowdesign / gist:361eb935a42daab5cf4c
Last active February 21, 2021 22:07
Touch events that behave exactly like mouse events while mouse dragging or touch moving.
// vars to keep track of the "mouse" during touchmove
var mouseX;
var mouseY;
// create the custom events so you can dispatch them later
var touchover = new Event("touchover");
var touchout = new Event("touchout");
var touchup = new Event("touchup");
var element = document.getElementById("dropTargetDivName");
@narrowdesign
narrowdesign / boatArrows
Created March 14, 2012 16:24
Arrow key navigation
// ADD THIS FOR ARROW KEY NAVIGATION on the home ticks and the photos on sub pages for maximum power!
$(document).bind("keydown", function (e) {
switch (e.keyCode) {
case 37: // LEFT ARROW
// trigger prev tick
break;
case 39: // RIGHT ARROW
// trigger next tick
break;
}
@narrowdesign
narrowdesign / ArrowKeyEvents
Created March 4, 2011 05:00
Arrow Key Events
$(document).keydown(function(e){
if (e.keyCode == 37) {
var previous = self.currentX;
self.currentX = self.limitXBounds(self.previousPageX(self.currentX));
if (self.currentX !== previous) {
self.update();
}
return false;
}else if (e.keyCode == 39) {
var previous = self.currentX;
@narrowdesign
narrowdesign / gist:94d1f78c48102203f68f
Last active September 14, 2015 14:29 — forked from trevorobrien/gist:c259d19323c6a0ecd8c8
Questions for yaro on taylor
character counts
branching on mobile
CSS pseudo classes
Verifying that +nick is my Bitcoin username. You can send me #bitcoin here: https://onename.io/nick
// variables get initialized up here. That way they're accessible from inside any of the functions below.
var playing = false; // nothing is happening until you click
var w = 500; // width of mouth frames
var l = 0; // keep track of left edge position of mouth sprite image
var mouthInterval; // you'll start and stop this below
var fps = 1000/30; // the second number is the fps
var aud = new Audio("audio/theRightTrack.mp3"); // load the audio before playing it
$( document ).ready(function() { // this is just jQuery saying "ready!" and will be in every javascript file you ever make. I put all my events and functions inside it
$('.gran').click(function(){