jQuery书架式图片鼠标滑过缩放显示



58 228 77



特效描述:jQuery 书架式图片 鼠标滑过 缩放显示,jQuery书架式图片鼠标滑过缩放显示

代码结构

1. HTML代码

<div id="bookrack">
    <a href="#" title="图片1"><img src="img/1.jpg" alt="jquery" /></a>
    <a href="#" title="图片2"><img src="img/2.jpg" alt="jquery" /></a>
    <a href="#" title="图片3"><img src="img/3.jpg" alt="jquery" /></a>
    <a href="#" title="图片4"><img src="img/4.jpg" alt="jquery" /></a>
    <a href="#" title="图片5"><img src="img/5.jpg" alt="jquery" /></a>
    <a href="#" title="图片6"><img src="img/6.jpg" alt="jquery" /></a>
    <a href="#" title="图片7"><img src="img/7.jpg" alt="jquery" /></a>
    <a href="#" title="图片8"><img src="img/8.jpg" alt="jquery" /></a>
    <a href="#" title="图片9"><img src="img/9.jpg" alt="jquery" /></a>
</div>
<script type="text/javascript">
var Bookrack = function(a, b, c, e) {
    this.scale = e || 0.4;
    this.x = b || 120;
    this.y = c || 160;
    this.border = 2;
    this.init(a);
    this.exec(Math.ceil(Math.random() * this.imgs.length))
};
Bookrack.prototype = {
    init: function(a) {
        this.width = a.clientWidth - 2 * this.x * this.scale;
        a.style.position = "relative";
        a.style.height = this.y + "px";
        this.imgs = a.getElementsByTagName("a");
        var b = this,
        c = document.createElement("span"),
        e,
        d;
        this.each(function(a, g) {
            a.style.position = "absolute";
            a.style.bottom = "0";
            a.style.border = this.border + "px solid gray";
            a.style.left = this.width * (g / this.imgs.length) + 2 * this.border + "px";
            a.setAttribute("dir", g);
            d = a.getElementsByTagName("img")[0].getAttribute("alt").split("|");
            e = c.cloneNode(!0);
            e.innerHTML = a.getAttribute("title");
            a.appendChild(e);
            a.onmouseover = function() {
                b.exec(this.getAttribute("dir"))
            }
        })
    },
    each: function(a) {
        for (var b = 0,
        c; c = this.imgs[b++];) a.call(this, c, b, this.imgs.length)
    },
    color: function(a) {
        a = (~~ (255 * a)).toString(16);
        2 > a.length && (a = "0" + a);
        a = a.substr(0, 2);
        return "#" + a + a + a
    },
    exec: function(a) {
        this.each(function(b, c, e, d, f) {
            b.getElementsByTagName("span")[0].style.display = "none";
            c == a && (b.getElementsByTagName("span")[0].style.display = "block");
            d = Math.min(c / a, a / c);
            f = Math.sin(90 * (Math.PI / 180) * d) * (1 - this.scale);
            b.style.zIndex = Math.ceil(1E4 * f);
            b.style.borderColor = this.color(f + this.scale);
            b.style.width = this.x * (f + this.scale) - 2 * this.border + "px";
            b.style.height = this.y * (f + this.scale) - 2 * this.border + "px";
            b.style.marginLeft = this.x * f / -2 + "px"
        })
    }
};
new Bookrack(document.getElementById('bookrack'), 120, 160);
</script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 滚动切换 滚动条切换 滑动选项卡 滑动切换 flash焦点图 flash幻灯片 flashbanner flash图片轮播 选项卡切换 选项卡 切换 tab切换 页面切换 选项卡插件 切换插件 滑动手风琴 滑动星星打分 焦点图 幻灯片 轮播图 bar焦点图 其他 带标题的焦点图 图片切换 图片选项卡 图标选项卡 缩放切换 鼠标滑过 鼠标悬停 跟随鼠标移动

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到