Skip to content

Commit f9542b1

Browse files
committed
fix base64 onload
1 parent a191102 commit f9542b1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: src/js/dreambox.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,20 @@
3636
}
3737

3838
var getButtonSet=function(panel,base64,cx,cy,mousedown,mouseup){
39+
var btn=$('<div style="position:absolute"></div>');
40+
panel.append(btn);
3941
var img=new Image();
42+
img.onload=function(){
43+
var w=img.width;
44+
var h=img.height;
45+
btn.css('left',Math.floor(cx-w/2)+'px');
46+
btn.css('top',Math.floor(cy-h/2)+'px');
47+
btn.css('width',w+'px');
48+
btn.css('height',h+'px');
49+
btn.css('background-image','url('+img.src+')');
50+
};
4051
img.src='data:image/png;base64,'+base64;
41-
var w=img.width;
42-
var h=img.height;
4352

44-
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+')"/>')
45-
panel.append(btn);
4653

4754
if (!mousedown)
4855
mousedown=return_false;

0 commit comments

Comments
 (0)