This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pseudocode to demonstrate batch rendering views | |
var $items = $('#items'); | |
var $wrap = $items.parent(); | |
$items.detach(); // this detaches the container element from the DOM | |
var dataset = data; // array of 1000 objects | |
for (var i = 0; i < dataset.length; i++) { | |
var myView = new ItemView({model: dataset[i]}); | |
$list.append(myView.render().el;); | |
} | |
// put container element into the DOM, which dumps all of the views into the page at once. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pseudocode to demonstrate lazy loading views | |
var $list = $('#list'); | |
var dataset = data; // array of 1000 objects | |
var preload = 50; | |
for (var i = 0; i < preload; i++) { | |
var view = new ItemView({model: dataset[i]}); | |
$list.append(view.render().el); | |
} | |
var $placeholders = $(); // jQuery collection to store placeholders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pseudocode demonstrating smart rendering with requestAnimationFrame | |
$(".item_column").on("scroll", function(){ | |
requestTick(); | |
}); | |
function requestTick() { | |
if (!isTicking) { | |
requestAnimationFrame(renderItemsInView); | |
} | |
isTicking = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pseudocode to demonstrate debouncing | |
$(".item_column").on("scroll", function(){ | |
// this function fires way too fast | |
getItemsInView(); | |
}); | |
// With debouncing: | |
$(".item_column").on("scroll", _.debounce(function(){ | |
// max this function can fire is every 150 milliseconds | |
getItemsInView(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pseudocode demonstrating finding elements in the current view | |
var $columns = $(".item_column"); | |
$columns.each(function(){ | |
var offset = $(this).offset(); | |
$topItem = document.elementFromPoint(offset.left + 5, offset.top + 5); | |
$bottomItem = document.elementFromPoint(offset.left + 5, $(this).height - 5); | |
var $renderItems = $topItem.nextUntil($bottomItem).add($bottomItem); | |
renderItems($renderItems); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<header> | |
<h1>3D Carousel Using TweenMax.js & jQuery</h1> | |
<h3>A pen by <a href="http://www.twitter.com/johnblazek" target="_blank">@johnblazek</a></h3> | |
<div id="fps">Framerate: 0/60 FPS</div> | |
</header> | |
<div id="contentContainer" class="trans3d"> | |
<section id="carouselContainer" class="trans3d"> | |
<figure id="item1" class="carouselItem trans3d"><div class="carouselItemInner trans3d">1</div></figure> | |
<figure id="item2" class="carouselItem trans3d"><div class="carouselItemInner trans3d">2</div></figure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<!-- Facebook sharing information tags --> | |
<meta property="og:title" content="*|MC:SUBJECT|*"> | |
<title>*|MC:SUBJECT|*</title> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'), | |
async = require('async'), | |
express = require('express'), | |
app = express(), | |
paypal_api = require('paypal-rest-sdk'); | |
paypal_api.configure({ | |
'host': 'api.paypal.com', | |
'port': '', | |
'client_id': ' live application client id ', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var targetElement = this.borderElement, | |
compareElement = item.borderElement, | |
bbox = targetElement.getBBox(), | |
transfromString = 'S' + [0.95, 0.95, (bbox.width/2), (bbox.height/2)] + '...', | |
newEl = targetElement.clone(), | |
smallerTransform = newEl.transform(transfromString).transform(), | |
path = newEl.attr('path').toString(), | |
tpath = Raphael.transformPath(path, smallerTransform), | |
itemPath = compareElement.attr('path').toString(), | |
tItemPath = Raphael.transformPath(itemPath, compareElement.transform()), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_src($dir, $filename, $res, $filetype) { | |
return $dir . $filename . ($res ? '@' . $res : '') . '.' . $filetype; | |
} | |
function picturefill($filename, $sizes, $filetype, $alt) { | |
$imgdir = get_template_directory_uri() . '/img/'; | |
$default = get_src($imgdir, $filename, null, $filetype); | |
$images = array(); |