| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1957 人关注过本帖
标题:牛逼的类似FLASH效果! 高手之间的对决!
只看楼主 加入收藏
bossyun
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-1-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:10 
牛逼的类似FLASH效果! 高手之间的对决!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网页转换</title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
    html {
        overflow: hidden;
    }
    body {
        margin: 0px;
        padding: 0px;

        width: 100%;
        height: 100%;
    }
    #imageFlow {
        position: absolute;
        width: 100%;
        height:95%;/*高度*/
        left: 0%;
        top: 10%;
        background: #CCCCCC;
    }
    #imageFlow .diapo {
        position: absolute;
        left: -1000px;
        cursor: pointer;
        -ms-interpolation-mode: nearest-neighbor;
    }
    #imageFlow .link {
        border: dotted #fff 1px;
        margin-left: -1px;
        margin-bottom: -1px;
    }
    #imageFlow .bank {
        visibility: hidden;
    }
    #imageFlow .top {
        position: absolute;
        width: 100%;
        height: 40%;
        background: #cccccc;
    }
    #imageFlow .text {
        position: absolute;
        left: 0px;
        width: 100%;
        bottom: 16%;
        text-align: center;
        color: #FFF;
        font-family: verdana, arial, Helvetica, sans-serif;
        z-index: 1000;
    }
    #imageFlow .title {
        font-size: 0.9em;
        font-weight: bold;
    }
    #imageFlow .legend {
        font-size: 0.8em;
    }
    #imageFlow .scrollbar {
        position: absolute;
        left: 10%;
        bottom: 10%;
        width: 80%;
        height: 16px;
        z-index: 1000;
    }
    #imageFlow .track {
        position: absolute;
        left: 1%;
        width: 98%;
        height: 16px;
        filter: alpha(opacity=30);
        opacity: 0.3;
    }
    #imageFlow .arrow-left {
        position: absolute;
    }
    #imageFlow .arrow-right {
    position: absolute;
    right: -1px;
    width: 29px;
    height: 16px;
    }
    #imageFlow .bar {
        position: absolute;
        height: 16px;
        left: 25px;
    }
</style>
<script type="text/javascript">

/*--创建IE-*/



var imf = function () {
    var lf = 0;
    var instances = [];
    function getElementsByClass (object, tag, className) {
        var o = object.getElementsByTagName(tag);
        for ( var i = 0, n = o.length, ret = []; i < n; i++)
            if (o[i].className == className) ret.push(o[i]);
        if (ret.length == 1) ret = ret[0];
        return ret;
    }
    function addEvent (o, e, f) {
        if (window.addEventListener) o.addEventListener(e, f, false);
        else if (window.attachEvent) r = o.attachEvent('on' + e, f);
    }
    function createReflexion (cont, img) {
        var flx = false;
        if (document.createElement("canvas").getContext) {
            flx = document.createElement("canvas");
            flx.width = img.width;
            flx.height = img.height;
            var context = flx.getContext("2d");
            context.translate(0, img.height);
            context.scale(1, -1);
            context.drawImage(img, 0, 0, img.width, img.height);
            context.globalCompositeOperation = "destination-out";
            var gradient = context.createLinearGradient(0, 0, 0, img.height * 2);
            gradient.addColorStop(1, "rgba(255, 255, 255, 0)");
            gradient.addColorStop(0, "rgba(255, 255, 255, 1)");
            context.fillStyle = gradient;
            context.fillRect(0, 0, img.width, img.height * 2);
        } else {
            /* ---- DX图像变换 ---- */
            flx     = document.createElement('img');
            flx.src = img.src;
            flx.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(' +
                               'opacity=50, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=' +
                               (img.height * .25) + ')';
        }
        /* ---- 插入倒影  
        flx.style.position = 'absolute';
        flx.style.left     = '-1000px';
        cont.appendChild(flx);
        return flx;----*/
    }
    /* //////////// ==== ImageFlow构造 ==== //////////// */
    function ImageFlow(oCont, size, zoom, border) {
        this.diapos     = [];
        this.scr        = false;
        this.size       = size;
        this.zoom       = zoom;
        this.bdw        = border;
        this.oCont      = oCont;
        this.oc         = document.getElementById(oCont);
        this.scrollbar  = getElementsByClass(this.oc,   'div', 'scrollbar');
        this.text       = getElementsByClass(this.oc,   'div', 'text');
        this.title      = getElementsByClass(this.text, 'div', 'title');
        this.legend     = getElementsByClass(this.text, 'div', 'legend');
        this.bar        = getElementsByClass(this.oc,   'img', 'bar');
        this.arL        = getElementsByClass(this.oc,   'img', 'arrow-left');
        this.arR        = getElementsByClass(this.oc,   'img', 'arrow-right');
        this.bw         = this.bar.width;
        this.alw        = this.arL.width - 5;
        this.arw        = this.arR.width - 5;
        this.bar.parent = this.oc.parent  = this;
        this.arL.parent = this.arR.parent = this;
        this.view       = this.back       = -1;
        this.resize();
        this.oc.onselectstart = function () { return false; }
        /* ---- 创建图像 ---- */
        var img   = getElementsByClass(this.oc, 'div', 'bank').getElementsByTagName('a');
        this.NF = img.length;
        for (var i = 0, o; o = img[i]; i++) {
            this.diapos[i] = new Diapo(this, i,
                                        o.rel,
                                        o.title || '- ' + i + ' -',
                                        o.innerHTML || o.rel,
                                        o.href || '',
                                        o.target || '_self'
            );
        }
        /* ==== 添加鼠标滚轮事件 ==== */
        if (window.addEventListener)
            this.oc.addEventListener('DOMMouseScroll', function(e) {
                this.parent.scroll(-e.detail);
            }, false);
        else this.oc.onmousewheel = function () {
            this.parent.scroll(event.wheelDelta);
        }
            /* ==== 滚动阻力N下降 ==== */
        this.bar.onmousedown = function (e) {
            if (!e) e = window.event;
            var scl = e.screenX - this.offsetLeft;
            var self = this.parent;
            /* ---- move bar ---- */
            this.parent.oc.onmousemove = function (e) {
                if (!e) e = window.event;
                self.bar.style.left = Math.round(Math.min((self.ws - self.arw - self.bw), Math.max(self.alw, e.screenX - scl))) + 'px';
                self.view = Math.round(((e.screenX - scl) ) / (self.ws - self.alw - self.arw - self.bw) * self.NF);
                if (self.view != self.back) self.calc();
                return false;
            }
            /* ---- 发布滚动 ---- */
            this.parent.oc.onmouseup = function (e) {
                self.oc.onmousemove = null;
                return false;
            }
            return false;
        }
        /* ==== 右箭 ==== */
        this.arR.onclick = this.arR.ondblclick = function () {
            if (this.parent.view < this.parent.NF - 1)
                this.parent.calc(1);
        }
        /* ==== 左箭 ==== */
        this.arL.onclick = this.arL.ondblclick = function () {
            if (this.parent.view > 0)
                this.parent.calc(-1);
        }
    }
    /* //////////// ==== ImageFlow 原型 ==== //////////// */
    ImageFlow.prototype = {
        /* ==== 目标 ==== */
        calc : function (inc) {
            if (inc) this.view += inc;
            var tw = 0;
            var lw = 0;
            var o = this.diapos[this.view];
            if (o && o.loaded) {
                /* ---- 重设 ---- */
                var ob = this.diapos[this.back];
                if (ob && ob != o) {
                    ob.img.className = 'diapo';
                    ob.z1 = 1;
                }
                /* ---- 更新 legend ---- */
                this.title.replaceChild(document.createTextNode(o.title), this.title.firstChild);
                this.legend.replaceChild(document.createTextNode(o.text), this.legend.firstChild);
                /* ---- 更新链接 ---- */
                if (o.url) {
                    o.img.className = 'diapo link';
                    window.status = 'hyperlink: ' + o.url;
                } else {
                    o.img.className = 'diapo';
                    window.status = '';
                }                                    
                /* ---- 计算目标大小及位置 ---- */
                o.w1 = Math.min(o.iw, this.wh ) * o.z1;
                var x0 = o.x1 = (this.wh * .5) - (o.w1 * .5);
                var x = x0 + o.w1 + this.bdw;
                for (var i = this.view + 1, o; o = this.diapos[i]; i++) {
                    if (o.loaded) {
                        o.x1 = x;
                        o.w1 = (this.ht / o.r) * this.size;
                        x   += o.w1 + this.bdw;
                        tw  += o.w1 + this.bdw;
                    }
                }
                x = x0 - this.bdw;
                for (var i = this.view - 1, o; o = this.diapos[i]; i--) {
                    if (o.loaded) {
                        o.w1 = (this.ht / o.r) * this.size;
                        o.x1 = x - o.w1;
                        x   -= o.w1 + this.bdw;
                        tw  += o.w1 + this.bdw;
                        lw  += o.w1 + this.bdw;
                    }
                }
                /* ---- 移动滚动条 ---- */
                if (!this.scr && tw) {
                    var r = (this.ws - this.alw - this.arw - this.bw) / tw;
                    this.bar.style.left = Math.round(this.alw + lw * r) + 'px';
                }
                /* ---- 保存预览视图 ---- */
                this.back = this.view;
            }
        },
        /* ==== 鼠标滚轮滚动 ==== */
        scroll : function (sc) {
            if (sc < 0) {
                if (this.view < this.NF - 1) this.calc(1);
            } else {
                if (this.view > 0) this.calc(-1);
            }
        },
        /* ==== 调整  ==== */
        resize : function () {
            this.wh = this.oc.clientWidth;
            this.ht = this.oc.clientHeight;
            this.ws = this.scrollbar.offsetWidth;
            this.calc();
            this.run(true);
        },
        /* ==== 移动所有图片  ==== */
        run : function (res) {
            var i = this.NF;
            while (i--) this.diapos[i].move(res);
        }
    }
    /* //////////// ====Diapo构造 ==== //////////// */
    Diapo = function (parent, N, src, title, text, url, target) {
        this.parent        = parent;
        this.loaded        = false;
        this.title         = title;
        this.text          = text;
        this.url           = url;
        this.target        = target;
        this.N             = N;
        this.img           = document.createElement('img');
        this.img.src       = src;
        this.img.parent    = this;
        this.img.className = 'diapo';
        this.x0            = this.parent.oc.clientWidth;
        this.x1            = this.x0;
        this.w0            = 0;
        this.w1            = 0;
        this.z1            = 1;
        this.img.parent    = this;
        this.img.onclick   = function() { this.parent.click(); }
        this.parent.oc.appendChild(this.img);
        /* ---- 显示外部链接 ---- */
        if (url) {
            this.img.onmouseover = function () { this.className = 'diapo link';    }
            this.img.onmouseout  = function () { this.className = 'diapo'; }
        }
    }
    /* //////////// ==== Diapo原型 ==== //////////// */
    Diapo.prototype = {
        /* ==== HTML渲染 ==== */
        move : function (res) {
            if (this.loaded) {
                var sx = this.x1 - this.x0;
                var sw = this.w1 - this.w0;
                if (Math.abs(sx) > 2 || Math.abs(sw) > 2 || res) {
                    /* ---- 当移动时只有PAINT ---- */
                    this.x0 += sx * .1;
                    this.w0 += sw * .1;
                    if (this.x0 < this.parent.wh && this.x0 + this.w0 > 0) {
                        /* ---- paint only 可见图片 ---- */
                        this.visible = true;
                        var o = this.img.style;
                        var h = this.w0 * this.r;
                        /* ---- diapo ---- */
                        o.left   = Math.round(this.x0) + 'px';
                        o.bottom = Math.floor(this.parent.ht * .25) + 'px';
                        o.width  = Math.round(this.w0) + 'px';
                        o.height = Math.round(h) + 'px';
                        /* ---- 倒影 ---- */
                        if (this.flx) {
                            var o = this.flx.style;
                            o.left   = Math.round(this.x0) + 'px';
                            o.top    = Math.ceil(this.parent.ht * .75 + 1) + 'px';
                            o.width  = Math.round(this.w0) + 'px';
                            o.height = Math.round(h) + 'px';
                        }
                    } else {
                        /* ---- 禁用隐形的图片 ---- */
                        if (this.visible) {
                            this.visible = false;
                            this.img.style.width = '0px';
                            if (this.flx) this.flx.style.width = '0px';
                        }
                    }
                }
            } else {
                /* ==== 图片的onload ==== */
                if (this. && this.img.width) {
                    /* ---- 得到大小的图片 ---- */
                    this.iw     = this.img.width;
                    this.ih     = this.img.height;
                    this.r      = this.ih / this.iw;
                    this.loaded = true;
                    /* ---- 创建倒影 ---- */
                    this.flx    = createReflexion(this.parent.oc, this.img);
                    if (this.parent.view < 0) this.parent.view = this.N;
                    this.parent.calc();
                }
            }
        },
        /* ==== diapo的OnClick ==== */
        click : function () {
            if (this.parent.view == this.N) {
                /* ---- click on zoomed diapo ---- */
                if (this.url) {
                    /* ---- 打开超链接 ---- */
                    window.open(this.url, this.target);
                } else {
                    /* ---- zoom in/out ---- */
                    this.z1 = this.z1 == 1 ? this.parent.zoom : 1;
                    this.parent.calc();
                }
            } else {
                /* ---- select diapo ---- */
                this.parent.view = this.N;
                this.parent.calc();
            }
            return false;
        }
    }
    /* //////////// ==== 公共方式 ==== //////////// */
    return {
        /* ==== 初始化脚本 ==== */
        create : function (div, size, zoom, border) {
            /* ---- 初始化 imageFlow ---- */
            var load = function () {
                var loaded = false;
                var i = instances.length;
                while (i--) if (instances[i].oCont == div) loaded = true;
                if (!loaded) {
                    /* ---- 推进新imageFlow实例 ---- */
                    instances.push(
                        new ImageFlow(div, size, zoom, border)
                    );
                    /* ---- 初始化脚本(once) ---- */
                    if (!imf.initialized) {
                        imf.initialized = true;
                        /* ---- 窗口resize事件 ---- */
                        addEvent(window, 'resize', function () {
                            var i = instances.length;
                            while (i--) instances[i].resize();
                        });
                        /* ---- 停止拖放N ---- */
                        addEvent(document.getElementById(div), 'mouseout', function (e) {
                            if (!e) e = window.event;
                            var tg = e.relatedTarget || e.toElement;
                            if (tg && tg.tagName == 'HTML') {
                                var i = instances.length;
                                while (i--) instances[i].oc.onmousemove = null;
                            }
                            return false;
                        });
                        /* ---- 设定的时间间隔循环 ---- */
                        setInterval(function () {
                            var i = instances.length;
                            while (i--) instances[i].run();
                        }, 16);
                    }
                }
            }
            /* ---- 窗口onload事件 ---- */
            addEvent(window, 'load', function () { load(); });
        }
    }
}();

/* ==== create imageFlow ==== */
//          div ID    , size, zoom, border
imf.create("imageFlow", 0.15, 1.5, 10);

</script>
</head>

<body>

<div id="imageFlow">
    <div class="top">
    </div>
    <div class="bank">
        
<a rel="http://i2. title="第二张" href="#"></a>
        <a rel="http://www. title="第三张" href="#"></a>
        <a rel="http://www.hb. title="第四张" href="#"></a> </div>    <div class="text">
        <div class="title">
            Loading</div>
        <div class="legend">
            Please wait...</div>
    </div>
    <div class="scrollbar">
        <img class="track" src="images/08081201sb.gif" alt="">
        <img class="arrow-left" src="images/08081201sl.gif" alt="">
        <img src="images/08081201sr.gif" alt="" height="16" width="25px;" class="arrow-right">
        <img class="bar" src="images/08081201sc.gif" alt=""> </div>
</div>

</body>

</html>





废话不多说了!
复制粘贴看效果!





搜索更多相关主题的帖子: FLASH 对决 效果 
2010-01-27 17:27
bossyun
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-1-27
收藏
得分:0 
如果你觉得是好作品请顶一个!
2010-01-27 17:29
foktime
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:奥斯维辛
等 级:贵宾
威 望:35
帖 子:795
专家分:2742
注 册:2009-9-4
收藏
得分:10 
呃 你下个ext看看就知道什么叫惊艳了
2010-01-28 08:28
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:10 
IEonly
2010-01-28 09:00
bossyun
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-1-27
收藏
得分:0 
回复 3楼 foktime
哪个 ext?
2010-01-28 09:50
bossyun
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-1-27
收藏
得分:0 
回复 4楼 aspic
看效果!
2010-01-28 09:50
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
好吧 我没看效果我就乱说话我错了 但是看了效果之后确实没见牛逼在哪里~很一般的效果
2010-01-29 09:05
bluecer
Rank: 2
等 级:论坛游民
帖 子:42
专家分:76
注 册:2007-4-25
收藏
得分:0 
LZ高手啊。
2010-02-23 20:58
kelly_zsl
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-6-5
收藏
得分:0 
好东西。。。挺流弊的。。。
2010-05-01 19:37
x_552346433
Rank: 2
等 级:论坛游民
帖 子:11
专家分:29
注 册:2011-4-6
收藏
得分:0 
惊艳......
2011-06-09 12:08
快速回复:牛逼的类似FLASH效果! 高手之间的对决!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.087524 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved