Skip to content

Commit

Permalink
fix base64 onload
Browse files Browse the repository at this point in the history
  • Loading branch information
chamspan committed Oct 6, 2013
1 parent a191102 commit f9542b1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/js/dreambox.js
Original file line number Diff line number Diff line change
@@ -36,13 +36,20 @@
}

var getButtonSet=function(panel,base64,cx,cy,mousedown,mouseup){
var btn=$('<div style="position:absolute"></div>');
panel.append(btn);
var img=new Image();
img.onload=function(){
var w=img.width;
var h=img.height;
btn.css('left',Math.floor(cx-w/2)+'px');
btn.css('top',Math.floor(cy-h/2)+'px');
btn.css('width',w+'px');
btn.css('height',h+'px');
btn.css('background-image','url('+img.src+')');
};
img.src='data:image/png;base64,'+base64;
var w=img.width;
var h=img.height;

var btn=$('<div style="position:absolute;left:'+Math.floor(cx-w/2)+';top:'+Math.floor(cy-h/2)+';width:'+w+';height:'+h+'; background-image:url('+img.src+')"/>')
panel.append(btn);

if (!mousedown)
mousedown=return_false;

0 comments on commit f9542b1

Please sign in to comment.