Created
January 5, 2015 20:47
-
-
Save CootCraig/5f4e2632bb4d3c2b4311 to your computer and use it in GitHub Desktop.
Load server image assets into Snap.svg
This file contains hidden or 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
index 0 has attr name El_Estudiante_de_la_tuna.jpg | |
index 0 has attr data-src /img/The_Spaniards_101-El_Estudiante_de_la_tuna.jpg | |
name El_Estudiante_de_la_tuna.jpg has loaded |
This file contains hidden or 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
doll = (function() { | |
var extern = {}; | |
var bigCircle = null; | |
var head = null; | |
var s = null; | |
s = Snap("#svg"); | |
head = Snap.load("/img/head.svg",function(head) { | |
head.select('#svg-head').attr({'transform-origin': "51.52 29.80", stroke: "#f00", fill: "#f00"}); | |
s.append(head); | |
}); | |
// /img/The_Spaniards_101-El_Estudiante_de_la_tuna.jpg | |
//s.append(document.getElementById("svg head")); | |
//bigCircle = s.circle(150, 150, 100); | |
//$("#svg-head").show(); | |
$('body').append( | |
$('<div id="image-assets-div" style="display: none" >') | |
); | |
$('#image-assets-div').append( | |
$('<img>').attr( { class: 'image-asset', | |
name: 'El_Estudiante_de_la_tuna.jpg', | |
'data-src': '/img/The_Spaniards_101-El_Estudiante_de_la_tuna.jpg' } ) | |
); | |
$('.image-asset').each(function(index,image_asset) { | |
if ($(image_asset).attr("name")) { | |
console.log('index ' + index.toString() + ' has attr name ' + $(image_asset).attr('name')); | |
if ($(image_asset).attr("data-src")) { | |
console.log('index ' + index.toString() + ' has attr data-src ' + $(image_asset).attr('data-src')); | |
$(image_asset).load(function(evt) { | |
console.log('name ' + $(evt.target).attr('name') + ' has loaded'); | |
}); | |
$(image_asset).attr("src",$(image_asset).attr('data-src')); | |
} | |
} | |
}); | |
//$('.image-asset').clone().appendTo($('body')); | |
return extern; | |
}) (); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment