Jquery实现仿腾讯娱乐频道焦点图(幻灯片)特效

2020-05-24 21:21:20易采站长站整理

        if (height == ‘100%’) {     // 自适应高度
            styleH = ‘100%’;
        } else {                    // 定高
            styleH = height + ‘px’;
        }
        el.style.width = styleW;
        el.style.height = styleH;
    };
    var readStyle = function(obj, name){
        if(obj.style[name]){
            return obj.style[name];
        }else if(obj.currentStyle){
            return obj.currentStyle[name]        }else if(document.defaultView && document.defaultView.getComputedStyle){
            var d=document.defaultView.getComputedStyle(obj,null);
            return d.getPropertyValue(name)
        }else{
            return null
        }
    };
    var style = {
        setOpacity : function(obj,opacity){
            if(typeof(obj.style.opacity) != ‘undefined’){
                obj.style.opacity = opacity;
            }else{
                obj.style.filter = ‘Alpha(Opacity=’ + (opacity*100) + ‘)’;
            };
        }
    };
    /* 动画 */
    var extend = {
        /**
         渐显元素
         @param {Element} target 目标元素
        **/
        fadeIn : function(obj,time){
            if(readStyle(obj, ‘display’) == ‘none’){
                obj.style.display = ‘block’;