기본 jQuery animate로는 backgroundcolor 효과를 줄 수 없다.
그래서 보면 jQuery ui plugin에 보면 모듈로 들어가 있는데..
이것저것 플러그인 붙이는게 싫은 사람들이 있고.. 가끔 저런 기능은 써쭤야 하고 그러면..
머 별건 아니지만.. 그부분만 가지고 와서.. 좀 min버전으로 만들어서 쓰면 되지 않을까 싶다.
뭐 남이 열심히 만들어 놓은걸 마음대로 편집해서 쓰고 싶은 맘은 없지만;; 특정부분만 쓰고 싶기에..
그리고
http://jquery.org/license/ 라이센스도 꽤나 자유로운 편이라;;
무튼.. 그래서.. 난..
/*
* jQuery UI Effects 1.8.16
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Effects/
*/
//override the animation for color styles
$.each(['backgroundColor'],
function(i, attr) {
$.fx.step[attr] = function(fx) {
if (!fx.colorInit) {
fx.start = getColor(fx.elem, attr);
fx.end = getRGB(fx.end);
fx.colorInit = true;
}
fx.elem.style[attr] = 'rgb(' +
Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
};
});
// Color Conversion functions from highlightFade
// By Blair Mitchelmore
// http://jquery.offput.ca/highlightFade/
// Parse strings looking for color tuples [255,255,255]
function getRGB(color) {
var result;
// Check if we're already dealing with an array of colors
if ( color && color.constructor == Array && color.length == 3 )
return color;
// Look for rgb(num,num,num)
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
// Look for rgb(num%,num%,num%)
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
// Look for #a0b1c2
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
// Look for #fff
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
return [255,255,255];
// Otherwise, we're most likely dealing with a named color
return [255,255,255];
}
function getColor(elem, attr) {
var color;
do {
color = $.curCSS(elem, attr);
// Keep going until we find an element that has color, or we hit the body
if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
break;
attr = "backgroundColor";
} while ( elem = elem.parentNode );
return getRGB(color);
};
colors부분은 그냥 지워버렸다;; 난 색상코드를 그대로 사용할꺼니까..
무튼 이렇게 해서 최대한 적은량으로 이펙트를.. ;;;
댓글을 달아 주세요
요즘은 메신저에도 잘 안보이는것 같더니 바뻤구나.. 화이팅! ㅎㅎ
2011.09.19 10:34 [ ADDR : EDIT/ DEL : REPLY ]메신저 접었습니다 ㅋㅋㅋ
2011.09.21 17:25 신고 [ ADDR : EDIT/ DEL ]