Skip to content

Instantly share code, notes, and snippets.

@hayes0724
hayes0724 / touch-handler.js
Created August 20, 2021 02:19
Class for creating touch and swipe events
export class TouchHandler {
#xDown = null
#yDown = null
/**
* Handles touch events for selected element
* @param {Element|string} element
*/
constructor(element) {
@hayes0724
hayes0724 / free-shipping.liquid
Created July 6, 2021 23:17
Free shipping calculator
{% liquid
assign required_amount = section.settings.free_shipping | times: 100
assign amount_needed = required_amount | minus: cart.total_price
assign percentage = required_amount | minus: cart.total_price | times: 100.0 | divided_by: required_amount | minus: 100 | abs | round | at_most: 100
%}
@hayes0724
hayes0724 / lazy-image.scss
Created June 23, 2021 22:28
Lazy Image CSS
$fade-in: opacity 400ms ease-in;
$fade-out: opacity 400ms 150ms ease-out;
img[data-sizes="auto"] {
display: block;
width: 100%;
}
.lazyload,
.lazyloading {
@hayes0724
hayes0724 / lazy-image.liquid
Last active January 3, 2022 20:25
Shopify lazysizes image
{%- comment -%}
Lazyload/Lazysizes responsive image snippet
Author: Eric Hayes
Version: 2.3
-------------------------------------
Requires:
image: {Obect} image object setting variable
Accepts:
@hayes0724
hayes0724 / crossfade.scss
Created October 11, 2020 21:51
Crossfade square image
.image__wrapper {
display: block;
position: relative;
height: 100%;
width: 100%;
padding: 50%;
img {
position: absolute;
top: 0;
bottom: 0;
/// @name Font Face
/// @description Loads woff/local type fonts
/// @version 1.0.2
/// @param {String} $font-family
/// @param {String} $fallback - fallback system font to use until main font is rendered [sans-serif]
/// @param {URL} $file - the URL of the font without extension, it will assume the woff type has the same file name
/// @param {String | Number} $weight [normal]
/// @param {String} $style [normal]
/*
{%- comment -%}
Lazyload/Lazysizes responsive picture snippet
Author: Eric Hayes
Version: 2.1
-------------------------------------
Requires:
image: {Obect} Desktop image object setting variable
Accepts:
image_container: {Boolean} Use an image container with padding for intrinsic size
@hayes0724
hayes0724 / track.html
Created September 29, 2018 01:35
BigCommerce - GA Enhanced Ecommerce Tracking
<script type="text/javascript">
window.dataLayer = window.dataLayer||[];
function trackGTMEcommerce() {
this._addTrans = addTrans;
this._addItem = addItems;
this._trackTrans = trackTrans;
}
var transaction = {};
transaction.transactionProducts = [];
// =============================================================================
// Responsive Font Sizes
// =============================================================================
//
// Viewport sized typography with minimum and maximum values
//
//
// @param {Number} $responsive - Viewport-based size
// @param {Number} $min - Minimum font size (px)
// @param {Number} $max - Maximum font size (px)
@hayes0724
hayes0724 / cal.js
Created June 14, 2015 17:55
Tiling/Flooring Calculator
function cal() {
// Get total square feet to cover
var sf = document.getElementById('sf').value;
console.log(sf)
// Get tile size
var tileSize = document.getElementById('tileSize').value;
console.log(tileSize)
// Convert area to inches and divide by a single tile's area (ex 4x4 tile = 16), then divide by 144 to determine tiles needed.
var total = (sf * 144)/tileSize;
console.log(total)