fix globalAlpha check so it doesn't barf in IE
This commit is contained in:
parent
848690c5b7
commit
b18accbfe7
1 changed files with 19 additions and 16 deletions
|
@ -332,8 +332,9 @@ var Pixastic = (function() {
|
|||
|
||||
return img;
|
||||
}
|
||||
} else if (Pixastic.Client.isIE() && typeof img.__pixastic_org_style != "undefined") {
|
||||
img.style.cssText = img.__pixastic_org_style;
|
||||
} else if (Pixastic.Client.isIE()) {
|
||||
if (typeof img.__pixastic_org_style != "undefined")
|
||||
img.style.cssText = img.__pixastic_org_style;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -364,24 +365,26 @@ var Pixastic = (function() {
|
|||
})(),
|
||||
|
||||
hasGlobalAlpha : (function() {
|
||||
var hasAlpha = false;
|
||||
var red = document.createElement("canvas");
|
||||
red.width = red.height = 1;
|
||||
var redctx = red.getContext("2d");
|
||||
redctx.fillStyle = "rgb(255,0,0)";
|
||||
redctx.fillRect(0,0,1,1);
|
||||
if (red.getContext) {
|
||||
red.width = red.height = 1;
|
||||
var redctx = red.getContext("2d");
|
||||
redctx.fillStyle = "rgb(255,0,0)";
|
||||
redctx.fillRect(0,0,1,1);
|
||||
|
||||
var blue = document.createElement("canvas");
|
||||
blue.width = blue.height = 1;
|
||||
var bluectx = red.getContext("2d");
|
||||
bluectx.fillStyle = "rgb(0,0,255)";
|
||||
bluectx.fillRect(0,0,1,1);
|
||||
var blue = document.createElement("canvas");
|
||||
blue.width = blue.height = 1;
|
||||
var bluectx = red.getContext("2d");
|
||||
bluectx.fillStyle = "rgb(0,0,255)";
|
||||
bluectx.fillRect(0,0,1,1);
|
||||
|
||||
redctx.globalAlpha = 0.5;
|
||||
redctx.drawImage(blue, 0, 0);
|
||||
var reddata = redctx.getImageData(0,0,1,1).data;
|
||||
|
||||
var hasAlpha = (reddata[2] != 255);
|
||||
redctx.globalAlpha = 0.5;
|
||||
redctx.drawImage(blue, 0, 0);
|
||||
var reddata = redctx.getImageData(0,0,1,1).data;
|
||||
|
||||
hasAlpha = (reddata[2] != 255);
|
||||
}
|
||||
return function() {
|
||||
return hasAlpha;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue