Skip to content

Instantly share code, notes, and snippets.

View lizlux's full-sized avatar

Liz Lee lizlux

  • Wikia
  • San Francisco
View GitHub Profile
@lizlux
lizlux / typescript-menu-aim
Last active April 10, 2021 19:25
Attempt at duplicating Amazon's triangle hover navigation menu
/**
* This plugin attempts to duplicate Amazon's triangle hover navigation menu.
* It's an adaptation of https://github.com/kamens/jQuery-menu-aim, written in Typescript, without jQuery
* See original plugin for documentation
*/
// tslint:disable no-use-before-declare
interface Options {
rowSelector?: string;
@lizlux
lizlux / index.html
Last active December 12, 2018 03:27
Testing window load with ajax call race condition
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
</head>
<body>
<h1>Test race condition</h1>
function init () {
let paragraph = document.querySelector('.entry-content p');
paragraph.addEventListener('click', clicked);
}
function clicked () {
console.log(this);
}
init();
@lizlux
lizlux / js-scope-jquery.js
Created June 6, 2016 22:29
JS Scope question with jQuery
var myObj = {
init: function () {
var paragraph = $('.entry-content p');
paragraph.on('click', this.clicked);
},
clicked: function () {
console.log(this);
}
};
@lizlux
lizlux / clean-code.js
Last active February 12, 2016 17:13
Clean Code Example
(function () {
var articleImage = document.querySelectorAll('.article img'),
nextArrow = document.getElementById('#nextArrow'),
previousArrow = document.getElementById('prevArrow');
articleImage.addEventListener('click', openGallery);
nextArrow.addEventListener('click', showNextImage)
previousArrow.addEventListener('click', showPreviousImage)
function openGallery() {
var gulp = require('gulp'),
ts = require('gulp-typescript'),
options = {
target: 'ES6',
noImplicitAny: true,
removeComments: false,
declarationFiles: false,
sortOutput: true,
suppressImplicitAnyIndexErrors: true
};