Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Barnett benbarnett

View GitHub Profile
@benbarnett
benbarnett / raphael-svg-buildjson
Created Jun 3, 2010
loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
View raphael-svg-buildjson
// loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
buildJSON = function(paper) {
var svgdata = [];
svgdata.push({
width: 390,
height: 400
});
$.each(paper,
We couldn’t find that file to show.
View tubeMapStations
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="2988.895px" height="1885.335px" viewBox="0 0 2988.895 1885.335" enable-background="new 0 0 2988.895 1885.335"
xml:space="preserve">
<text transform="matrix(1 0 0 1 117.5674 193.3823)" fill="#1C3F94" font-family="'ArialMT'" font-size="13.7317">Amersham</text>
<text transform="matrix(1 0 0 1 285.0654 207.4351)" fill="#1C3F94" font-family="'ArialMT'" font-size="13.7317">Chorleywood</text>
<text transform="matrix(1 0 0 1 1316.9741 261.0347)" fill="#1C3F94" font-family="'ArialMT'" font-size="13.7317">Mill Hill East</text>
<text transform="matrix(1 0 0 1 306.2056 236.7271)" fill="#1C3F94" font-family="'ArialMT'" font-size="13.7317">Rickmansworth</t
View tubeMapLines.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benbarnett
benbarnett / jquery-animate-enhanced-demo.js
Created Nov 8, 2010
demo code on jquery anim enhanced plugin home
View jquery-animate-enhanced-demo.js
$('button#start').click(function() {
var results = $('p#results').html("Animating..."),
button = $(this).attr('disabled', 'disabled');
// CSS3 Container
$('.target-css').animate({left: "+=200px", width:320 }, 1500, function() {
results.html('first callback() fired, reversing...');
$(this).animate({left: "-=200px", width:280 }, 1500, function() {
results.html("second callback() fired");
button.removeAttr('disabled');
@benbarnett
benbarnett / youtube-html5-switch.js
Created Nov 24, 2010
Detect Flash support and revert to standard YouTube embed code to enable HTML5 player
View youtube-html5-switch.js
if (swfobject.hasFlashPlayerVersion("8.0.0")) {
// insert the chromeless player with custom controls and skinning
alert('you have flash, so getting the chromeless/skinned player');
// Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always" };
// The element id of the Flash embed
var atts = { id: "ytPlayer" };
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
@benbarnett
benbarnett / jquery.fn.translation.js
Created Dec 22, 2010
Calculate translation from transform matrix
View jquery.fn.translation.js
function translation(elem) {
var cssPrefixes = ["", "-webkit-", "-moz-", "-o-"],
cStyle = window.getComputedStyle(elem, null),
translation = {
x: 0,
y: 0
};
for (var i = cssPrefixes.length - 1; i >= 0; i--){
var transform = cStyle.getPropertyValue(cssPrefixes[i] + "transform");
You can’t perform that action at this time.