Skip to content

Instantly share code, notes, and snippets.

View foleyatwork's full-sized avatar

Kevin Foley foleyatwork

View GitHub Profile
@foleyatwork
foleyatwork / SiteWithController.js
Last active September 8, 2015 16:56
An example of a site.js file that works well with sqs-controller.
/**
* This variable gets added to "window" and becomes
* the global namespace for your site.
*
* @namespace Site
* @global
*/
var Site = {};
/**
* Creates a grid with static gutters.
*
* @mixin grid--static-gutter
* @param {Number} columns The number of columns in your grid.
* @param {Number} gutter Gutters, set in pixels regardless of any unit passed.
*/
.grid--static-gutter(@columns: 2, @gutter) {
@width: 100 / @columns;
@marginRight: @gutter * (@columns - 1) / @columns;
@foleyatwork
foleyatwork / ImageLoader-examples.js
Last active August 3, 2022 14:37
How to run Squarespace's ImageLoader manually.
// For all images.
var allImages = document.querySelectorAll('img[data-src]');
for (var i = 0; i < allImages.length; i++) {
ImageLoader.load(allImages[i]);
}
// For a single image.
@foleyatwork
foleyatwork / gist:8969411
Last active August 29, 2015 13:56
Disables all pointer events on scroll for 60fps scrolling. Thanks to Paul Irish (source: http://www.thecssninja.com/javascript/pointer-events-60fps).
(function () {
var css = '.disable-hover, .disable-hover * { pointer-events: none !important; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style'),
body = document.body,
timer;
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
YUI().use('node', 'anim', function (Y) {
Y.on('domready', function () {
(function () {
Y.one('body').delegate('click', function (e) {
e.preventDefault();
var anchor = e.currentTarget.getAttribute('href');
var scrollAnim = new Y.Anim({
node: Y.one(Y.UA.gecko || Y.UA.ie || !!navigator.userAgent.match(/Trident.*rv.11\./) ? 'html' : 'body'),
to: {
scrollTop : Y.one(anchor).getY()
@foleyatwork
foleyatwork / featured.block
Last active December 12, 2015 06:49
The featured posts block dynamically pulls in featured posts from any collection with any category filter or tag filter.