Skip to content

Commit

Permalink
现在只支持变形中的旋转效果
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Nov 25, 2012
1 parent 40bcfdf commit 428066b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 6 additions & 9 deletions css.js
Expand Up @@ -91,7 +91,6 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
$.fn.css = function( name, value , neo){
return $.access( this, name, value, $.css );
}

var cssPair = {
Width:['Left', 'Right'],
Height:['Top', 'Bottom']
Expand Down Expand Up @@ -158,8 +157,9 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
}
return val;
};

//========================= 处理 width, height, innerWidth, innerHeight, outerWidth, outerHeight ========
var rmapper = /(\w+)_(\w+)/g
//生成width, height, innerWidth, innerHeight, outerWidth, outerHeight这六种原型方法
"Height,Width".replace( $.rword, function( name ) {
var lower = name.toLowerCase(),
clientProp = "client" + name,
Expand Down Expand Up @@ -201,7 +201,7 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
})

});

//========================= 处理 show hide toggle =========================
var sandbox,sandboxDoc;
$.callSandbox = function(parent,callback){
if ( !sandbox ) {
Expand All @@ -217,7 +217,6 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
callback(sandboxDoc);
parent.removeChild(sandbox);
}

var cacheDisplay = $.oneObject("a,abbr,b,span,strong,em,font,i,img,kbd","inline");
var blocks = $.oneObject("div,h1,h2,h3,h4,h5,h6,section,p","block");
$.mix(cacheDisplay ,blocks);
Expand Down Expand Up @@ -275,8 +274,7 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
return toggelDisplay( this, typeof state == "boolean" ? state : -1 );
}

//=======================================================

//========================= 处理 offset =========================
function setOffset(node, options){
if(node && node.nodeType == 1 ){
var position = $.css( node, "position" );
Expand Down Expand Up @@ -342,7 +340,7 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct

return pos;
}

//========================= 处理 position =========================
$.fn.position = function() {//取得元素相对于其offsetParent的坐标
var offset, offsetParent , node = this[0],
parentOffset = {//默认的offsetParent相对于视窗的距离
Expand Down Expand Up @@ -394,7 +392,7 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
}
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
}

//========================= 处理 scrollLeft scrollTop =========================
"scrollLeft_pageXOffset,scrollTop_pageYOffset".replace( rmapper, function(_, method, prop ) {
$.fn[ method ] = function( val ) {
var node, win, top = method == "scrollTop";
Expand Down Expand Up @@ -426,7 +424,6 @@ define( "css", !!top.getComputedStyle ? ["$node"] : ["$node","$css_fix"] , funct
return el.type === "hidden" || $.css( el, "display") === "none" ;
}
}

function getWindow( node ) {
return $.type(node,"Window") ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false;
} ;
Expand Down
8 changes: 4 additions & 4 deletions css_fix.js
Expand Up @@ -116,6 +116,7 @@ define("css_fix", !!top.getComputedStyle, function(){
var style = node.currentStyle;
return style.backgroundPositionX +" "+style.backgroundPositionX
};
//========================= 处理 rotate =========================
var stransform = "DXImageTransform.Microsoft.Matrix";
adapter.centerOrigin = "margin"
adapter[ "rotate:set" ] = function(node, name, value){
Expand All @@ -130,10 +131,9 @@ define("css_fix", !!top.getComputedStyle, function(){
matrix.M12 = -sintheta;
matrix.M21 = sintheta;
matrix.M22 = costheta;
if((name = adapter.centerOrigin)) {
node.style[name == 'margin' ? 'marginLeft' : 'left'] = -(node.offsetWidth/2) + (node.clientWidth/2) + "px";
node.style[name == 'margin' ? 'marginTop' : 'top'] = -(node.offsetHeight/2) + (node.clientHeight/2) + "px";
}
name = adapter.centerOrigin;
node.style[name == 'margin' ? 'marginLeft' : 'left'] = -(node.offsetWidth/2) + (node.clientWidth/2) + "px";
node.style[name == 'margin' ? 'marginTop' : 'top'] = -(node.offsetHeight/2) + (node.clientHeight/2) + "px";
}
});
//2011.10.21 去掉opacity:setter 的style.visibility处理
Expand Down

0 comments on commit 428066b

Please sign in to comment.