多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > web前端 > htmlcss > jquery + css 特效 之 一款基于jQuery/CSS3實(shí)現(xiàn)拼圖效果的相冊(cè)

jquery + css 特效 之 一款基于jQuery/CSS3實(shí)現(xiàn)拼圖效果的相冊(cè)

來(lái)源:程序員人生   發(fā)布時(shí)間:2015-02-16 19:51:53 閱讀次數(shù):4008次

     今天我們要來(lái)分享1款很酷的jQuery相冊(cè)插件,首先相冊(cè)中的圖片會(huì)以1定的角度傾斜放置在頁(yè)面上,點(diǎn)擊圖片縮略圖就能夠展開(kāi)圖片,并且圖片是由所有縮略圖拼接而成,圖片展開(kāi)和收攏的動(dòng)畫(huà)效果也非常不錯(cuò)。固然圖片傾斜需要CSS3支持。效果圖以下:


本章主要參照了以下文章進(jìn)行學(xué)習(xí)

jquery:http://www.itmmd.com/tag/jquery.html

jQuery教程(31)-jQuery插件開(kāi)發(fā)之全局函數(shù)插件
jQuery教程(30)-jQuery插件開(kāi)發(fā)之自定義選擇符
jQuery教程(29)-jQuery插件開(kāi)發(fā)之為插件方法指定參數(shù)
jQuery教程(28)-jQuery插件開(kāi)發(fā)之使用插件
jQuery教程(27)-jQueryajax操作之修改默許選項(xiàng)


實(shí)現(xiàn)的代碼。

html代碼:

復(fù)制代碼
<div id="im_wrapper" class="im_wrapper"> <div style="background-position: 0px 0px;"> <img src="images/thumbs/1.jpg" alt="" /></div> <div style="background-position: ⑴25px 0px;"> <img src="images/thumbs/2.jpg" alt="" /></div> <div style="background-position: ⑵50px 0px;"> <img src="images/thumbs/3.jpg" alt="" /></div> <div style="background-position: ⑶75px 0px;"> <img src="images/thumbs/4.jpg" alt="" /></div> <div style="background-position: ⑸00px 0px;"> <img src="images/thumbs/5.jpg" alt="" /></div> <div style="background-position: ⑹25px 0px;"> <img src="images/thumbs/6.jpg" alt="" /></div> <div style="background-position: 0px ⑴25px;"> <img src="images/thumbs/7.jpg" alt="" /></div> <div style="background-position: ⑴25px ⑴25px;"> <img src="images/thumbs/8.jpg" alt="" /></div> <div style="background-position: ⑵50px ⑴25px;"> <img src="images/thumbs/9.jpg" alt="" /></div> <div style="background-position: ⑶75px ⑴25px;"> <img src="images/thumbs/10.jpg" alt="" /></div> <div style="background-position: ⑸00px ⑴25px;"> <img src="images/thumbs/11.jpg" alt="" /></div> <div style="background-position: ⑹25px ⑴25px;"> <img src="images/thumbs/12.jpg" alt="" /></div> <div style="background-position: 0px ⑵50px;"> <img src="images/thumbs/13.jpg" alt="" /></div> <div style="background-position: ⑴25px ⑵50px;"> <img src="images/thumbs/14.jpg" alt="" /></div> <div style="background-position: ⑵50px ⑵50px;"> <img src="images/thumbs/15.jpg" alt="" /></div> <div style="background-position: ⑶75px ⑵50px;"> <img src="images/thumbs/16.jpg" alt="" /></div> <div style="background-position: ⑸00px ⑵50px;"> <img src="images/thumbs/17.jpg" alt="" /></div> <div style="background-position: ⑹25px ⑵50px;"> <img src="images/thumbs/18.jpg" alt="" /></div> <div style="background-position: 0px ⑶75px;"> <img src="images/thumbs/19.jpg" alt="" /></div> <div style="background-position: ⑴25px ⑶75px;"> <img src="images/thumbs/20.jpg" alt="" /></div> <div style="background-position: ⑵50px ⑶75px;"> <img src="images/thumbs/21.jpg" alt="" /></div> <div style="background-position: ⑶75px ⑶75px;"> <img src="images/thumbs/22.jpg" alt="" /></div> <div style="background-position: ⑸00px ⑶75px;"> <img src="images/thumbs/23.jpg" alt="" /></div> <div style="background-position: ⑹25px ⑶75px;"> <img src="images/thumbs/24.jpg" alt="" /></div> </div> <div id="im_loading" class="im_loading"> </div> <div id="im_next" class="im_next"> </div> <div id="im_prev" class="im_prev"> </div> <div> </div>
復(fù)制代碼

js代碼:

復(fù)制代碼
(function ($, sr) { var debounce = function (func, threshold, execAsap) { var timeout; return function debounced() { var obj = this, args = arguments; function delayed() { if (!execAsap) func.apply(obj, args); timeout = null; }; if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; } //smartresize jQuery.fn[sr] = function (fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery, 'smartresize'); </script> <script type="text/javascript"> $(function () { //check if the user made the //mistake to open it with IE var ie = false; if ($.browser.msie) ie = true; //flag to control the click event var flg_click = true; //the wrapper var $im_wrapper = $('#im_wrapper'); //the thumbs var $thumbs = $im_wrapper.children('div'); //all the images var $thumb_imgs = $thumbs.find('img'); //number of images var nmb_thumbs = $thumbs.length; //image loading status var $im_loading = $('#im_loading'); //the next and previous buttons var $im_next = $('#im_next'); var $im_prev = $('#im_prev'); //number of thumbs per line var per_line = 6; //number of thumbs per column var per_col = Math.ceil(nmb_thumbs / per_line) //index of the current thumb var current = ⑴; //mode = grid | single var mode = 'grid'; //an array with the positions of the thumbs //we will use it for the navigation in single mode var positionsArray = []; for (var i = 0; i < nmb_thumbs; ++i) positionsArray[i] = i; //preload all the images $im_loading.show(); var loaded = 0; $thumb_imgs.each(function () { var $this = $(this); $('<img/>').load(function () { ++loaded; if (loaded == nmb_thumbs * 2) start(); }).attr('src', $this.attr('src')); $('<img/>').load(function () { ++loaded; if (loaded == nmb_thumbs * 2) start(); }).attr('src', $this.attr('src').replace('/thumbs', '')); }); //starts the animation function start() { $im_loading.hide(); //disperse the thumbs in a grid disperse(); } //disperses the thumbs in a grid based on windows dimentions function disperse() { if (!flg_click) return; setflag(); mode = 'grid'; //center point for first thumb along the width of the window var spaces_w = $(window).width() / (per_line + 1); //center point for first thumb along the height of the window var spaces_h = $(window).height() / (per_col + 1); //let's disperse the thumbs equally on the page $thumbs.each(function (i) { var $thumb = $(this); //calculate left and top for each thumb, //considering how many we want per line var left = spaces_w * ((i % per_line) + 1) - $thumb.width() / 2; var top = spaces_h * (Math.ceil((i + 1) / per_line)) - $thumb.height() / 2; //lets give a random degree to each thumb var r = Math.floor(Math.random() * 41) - 20; /* now we animate the thumb to its final positions; we also fade in its image, animate it to 115x115, and remove any background image of the thumb - this is not relevant for the first time we call disperse, but when changing from single to grid mode */ if (ie) var param = { 'left': left + 'px', 'top': top + 'px' }; else var param = { 'left': left + 'px', 'top': top + 'px', 'rotate': r + 'deg' }; $thumb.stop() .animate(param, 700, function () { if (i == nmb_thumbs - 1) setflag(); }) .find('img') .fadeIn(700, function () { $thumb.css({ 'background-image': 'none' }); $(this).animate({ 'width': '115px', 'height': '115px', 'marginTop': '5px', 'marginLeft': '5px' }, 150); }); }); } //controls if we can click on the thumbs or not //if theres an animation in progress //we don't want the user to be able to click function setflag() { flg_click = !flg_click } /* when we click on a thumb, we want to merge them and show the full image that was clicked. we need to animate the thumbs positions in order to center the final image in the screen. The image itself is the background image that each thumb will have (different background positions) If we are currently seeing the single image, then we want to disperse the thumbs again, and with this, showing the thumbs images. */ $thumbs.bind('click', function () { if (!flg_click) return; setflag(); var $this = $(this); current = $this.index(); if (mode == 'grid') { mode = 'single'; //the source of the full image var image_src = $this.find('img').attr('src').replace('/thumbs', ''); $thumbs.each(function (i) { var $thumb = $(this); var $image = $thumb.find('img'); //first we animate the thumb image //to fill the thumbs dimentions $image.stop().an
生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線(xiàn)----------------------------
分享到:
------分隔線(xiàn)----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 久久丝袜精品综合网站 | 国产偷v国产偷v亚洲高清 | 中文字幕天天躁夜夜狠狠综合 | 波多野结衣成人 | 精品一区二区三区高清免费不卡 | 欧美成人精品一区二三区在线观看 | 欧美日韩中文亚洲另类春色 | 欧美人与黑人交 | 国产大片51精品免费观看 | 在线一级毛片 | 纯欧美一级毛片_免费 | 最近高清中文字幕大全1 | 一本久草 | 国产91精品高清一区二区三区 | 欧美日韩中文亚洲v在线综合 | 男女男精品视频 | 亚洲精品久久99久久一区 | 亚洲永久免费视频 | 男女激情视频在线观看 | 91九色精品国产 | 网站免费视频 | 黑人巨大xxx | 国产亚洲精品福利片 | 国产一级做人爱c黑人版 | 亚洲成人黄色在线观看 | 欧美国产日韩久久久 | 91久久偷偷做嫩草影院 | 日韩一区二三区无 | 日本免费乱人伦在线观看 | 天天做天天爱天天爽综合网 | 视频在线网站 | 又硬又大又湿又紧a视频 | 欧美精品videossex17 | 国产福利精品一区二区 | 亚洲尤物视频 | 91性视频| 一二三四视频社区在线中文 | 国产一区免费在线观看 | 欧美日韩永久久一区二区三区 | 欧美18videosex初次| 欧美性猛交xxxx乱大交中文 |