Skip to content

Commit bb6bab0

Browse files
committed
Refactor cocos2d#3370: Avoid overwrite user’s custom body style
1 parent 0d28b08 commit bb6bab0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

cocos2d/core/platform/CCEGLView.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,21 @@ cc.ContainerStrategy = cc.Class.extend({
871871
locContainer.style.width = w + "px";
872872
locContainer.style.height = h + "px";
873873

874-
var body = document.body;
875-
if (body)
876-
body.style.padding = body.style.border = body.style.margin = 0 + "px";
874+
var body = document.body, style;
875+
if (body && (style = body.style)) {
876+
style.paddingTop = style.paddingTop || "0px";
877+
style.paddingRight = style.paddingRight || "0px";
878+
style.paddingBottom = style.paddingBottom || "0px";
879+
style.paddingLeft = style.paddingLeft || "0px";
880+
style.borderTop = style.borderTop || "0px";
881+
style.borderRight = style.borderRight || "0px";
882+
style.borderBottom = style.borderBottom || "0px";
883+
style.borderLeft = style.borderLeft || "0px";
884+
style.marginTop = style.marginTop || "0px";
885+
style.marginRight = style.marginRight || "0px";
886+
style.marginBottom = style.marginBottom || "0px";
887+
style.marginLeft = style.marginLeft || "0px";
888+
}
877889
},
878890

879891
_fixContainer: function () {

0 commit comments

Comments
 (0)