手册网
参考手册
在线工具
在线文档
在线代码
素材大全
推荐
导航
在线手册 »
WEB优质项目
开放平台
工具软件
CSS3.0中文手册
jQuery 1.8 参考手册
HTML4参考手册
HTML基础手册
HTML快速参考手册
MySQL5.1中文参考手册
JavaScript参考手册
Delphi6函数大全
Delphi7参考手册
SQL基础教程
jQuery 1.10 中文参考手册
CSS2 参考手册
ASP参考手册
C/C++中文手册
django中文教程
DOS命令大全
jQueryEasyUI1.3中文手册
Hibernate3.2中文参考文档
Html4.01参考手册
JAVA学习笔记
JSP中文教程
Linux参考手册
Lua5参考手册
Oracle参考手册
Phpcmsv9二次开发手册
phpwind二次开发手册
PostgreSQL参考手册
Python2中文手册
Spring2.5中文参考手册
XML参考手册
正则表达式参考手册
jQuery 1.11.3 中文参考手册
ThinkPHP3.2.2完全开发手册
ThinkPHP3.2.3完全开发手册
yii1和php5开发
ThinkPHP5.0完全开发手册
jQuery 3.1 参考手册
Underscore1.8.3 参考手册
Swift3 中文手册
Sass 3.4.21 中文手册
Backbone.js 1.1.2 API中文文档
JSDoc 参考手册
Webpack 2.2 中文文档
JavaScript 全栈教程
Nginx 中文官方手册
CSS4.2.4 参考手册
ThinkPHP5.1完全开发手册.CHM
HTML/CSS »
Html
Bootstrap
HTML5
CSS
CSS3
Foundation
JavaScript »
JavaScript
jQuery
HTML DOM
AngularJS
jQuery UI
jQuery EasyUI
Node.js
JSON
Highcharts
AJAX
React
jQuery插件大全
AlloyUI
Vue.js v2.0 中文
Vuex
vue-router
Underscore.js
Zepto.js
程序设计 »
PHP
Java
JSP
Python
Python3
Django
Linux
Ruby
C
C++
Servlet
Lua
Go
设计模式
正则表达式
ASP
AppML
VBScript
Scala
数据库 »
SQL
MySQL
SQLite
MongoDB
Redis
Memcached
移动端 »
jQuery Mobile
Android
ionic
IOS
Sencha Touch
Clouda+
efe
Frozen UI
Amaze UI
CardKit
App.js
Mobile Angular UI
Kendo UI
PhoneGap
Framework7
Junior
Jingle
mui
SUI Mobile
ReactNative
Weex
APICloud
Wex5
Ratchet
HTML5plus
Plane UI
Swift 教程
XML 教程 »
XML
DTD
XML DOM
XSLT
XPath
XQuery
XLink
XML Schema
XSLFO
SVG
ASP.NET »
ASP.NET
C#
开发工具 »
Eclipse
Git
Firebug
SVN 教程
Chrome 控制台
开源项目 »
Yii中文参考手册
Yii1开发教程
Yii2开发教程
ThinkPHP3.1开发教程
ThinkPHP3.2.3开发教程
地图开发
Wordpress
Laravel中文文档
Web Service »
Web Service 教程
WSDL 教程
SOAP 教程
RDF 教程
RSS 教程
转码工具 »
HTML/JavaScript格式化
CSS 格式化/压缩
JS格式化/加密/压缩
Native互换Unicode大全
日期格式化工具
Markdown转HTML
CSS 整理压缩
JSON 在线解析
短网址生成
代码处理 »
进制互换大全
16进制互换RGB
简体转繁体
汉字转拼音
小写转大写
大写转小写
加密和解密
繁体转简体
实用工具 »
Bootstrap图标定制
CSS 颜色选择器
字数统计
正则表达式测试
htpasswd 生成器
全世界数据库
IP归属地查询
实用计算器
生成二维码
ICO图标制作
CSS3 气泡对话框
CSS & JS Hack 大全
CSS3 背景渐变色生成器
CSS3 阴影边框生成器
CSS3 动画工具
Web 常用字体演示
CSS3 选择器演示
CSS 中文字体 Unicode 编码表
CSS3 GitHub Buttons
CSS Webkit 自定义滚动条样式
在线自动分词
ionic图标
阿里巴巴矢量图标库
IcoMoon 图标库
CSS3 代码生成
CSS3 Flexbox 演示
便民工具 »
快递查询
安全期计算器
周公解梦
笑话大全
常用对照表 »
HTTP Content-type 详细对照表
HTML特殊转义字符对照表
ASCII对照表
HTTP状态码详解
运算符优先级
TCP/UDP常见端口参考
经典小游戏 »
像素小鸟
爱消除
飞更高
俄罗斯方块
台球
贪吃蛇
拼图魔方
坦克大战
解救公主
中国象棋
压扁小鸟
打飞字
Flappy小鸟
登陆
实例代码
“Ctrl+/”
提示
“F11/ESC”
全屏
返回
格式化
恢复
运行
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>演示:jQuery相册拼图插件</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" href="/api/jq/5733e34e86f1e/css/style.css" type="text/css" media="screen"/> <script src="/api/jq/5733e34e86f1e/js/cufon-yui.js" type="text/javascript"></script> <script src="/api/jq/5733e34e86f1e/js/ChunkFive_400.font.js" type="text/javascript"></script> <script type="text/javascript"> Cufon.replace('h1', {textShadow: '1px 1px #fff'}); Cufon.replace('.description', {textShadow: '1px 1px #fff'}); Cufon.replace('a', {textShadow: '1px 1px #fff', hover: true}); </script> <style type="text/css"> .description{ position:fixed; right:10px; top:10px; font-size:12px; color:#888; } span.reference{ position:fixed; left:10px; bottom:10px; font-size:12px; } span.reference a{ color:#888; text-transform:uppercase; text-decoration:none; padding-right:20px; } span.reference a:hover{ color:#444; } </style> </head> <body> <div id="im_wrapper" class="im_wrapper"> <div style="background-position:0px 0px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/1.jpg" alt="" /></div> <div style="background-position:-125px 0px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/2.jpg" alt="" /></div> <div style="background-position:-250px 0px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/3.jpg" alt="" /></div> <div style="background-position:-375px 0px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/4.jpg" alt="" /></div> <div style="background-position:-500px 0px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/5.jpg" alt="" /></div> <div style="background-position:-625px 0px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/6.jpg" alt="" /></div> <div style="background-position:0px -125px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/7.jpg" alt="" /></div> <div style="background-position:-125px -125px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/8.jpg" alt="" /></div> <div style="background-position:-250px -125px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/9.jpg" alt="" /></div> <div style="background-position:-375px -125px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/10.jpg" alt="" /></div> <div style="background-position:-500px -125px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/11.jpg" alt="" /></div> <div style="background-position:-625px -125px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/12.jpg" alt="" /></div> <div style="background-position:0px -250px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/13.jpg" alt="" /></div> <div style="background-position:-125px -250px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/14.jpg" alt="" /></div> <div style="background-position:-250px -250px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/15.jpg" alt="" /></div> <div style="background-position:-375px -250px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/16.jpg" alt="" /></div> <div style="background-position:-500px -250px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/17.jpg" alt="" /></div> <div style="background-position:-625px -250px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/18.jpg" alt="" /></div> <div style="background-position:0px -375px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/19.jpg" alt="" /></div> <div style="background-position:-125px -375px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/20.jpg" alt="" /></div> <div style="background-position:-250px -375px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/21.jpg" alt="" /></div> <div style="background-position:-375px -375px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/22.jpg" alt="" /></div> <div style="background-position:-500px -375px;"><img src="/api/jq/5733e34e86f1e/images/thumbs/23.jpg" alt="" /></div> <div style="background-position:-625px -375px;"><img src="/api/jq/5733e34e86f1e/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> <!-- The JavaScript --> <script type="text/javascript" src="/api/jq/5733e34e86f1e/js/jquery.min.js"></script> <script src="/api/jq/5733e34e86f1e/js/jquery.transform-0.9.1.min.js"></script> <script type="text/javascript"> (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 /api/jq/5733e34e86f1e/images var $thumb_imgs = $thumbs.find('img'); //number of /api/jq/5733e34e86f1e/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 = -1; //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 /api/jq/5733e34e86f1e/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 /api/jq/5733e34e86f1e/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().animate({ 'width': '100%', 'height': '100%', 'marginTop': '0px', 'marginLeft': '0px' }, 150, function() { //calculate the dimentions of the full image var f_w = per_line * 125; var f_h = per_col * 125; var f_l = $(window).width() / 2 - f_w / 2 var f_t = $(window).height() / 2 - f_h / 2 /* set the background image for the thumb and animate the thumbs postions and rotation */ if (ie) var param = { 'left': f_l + (i % per_line) * 125 + 'px', 'top': f_t + Math.floor(i / per_line) * 125 + 'px' }; else var param = { 'rotate': '0deg', 'left': f_l + (i % per_line) * 125 + 'px', 'top': f_t + Math.floor(i / per_line) * 125 + 'px' }; $thumb.css({ 'background-image': 'url(' + image_src + ')' }).stop() .animate(param, 1200, function() { //insert navigation for the single mode if (i == nmb_thumbs - 1) { addNavigation(); setflag(); } }); //fade out the thumb's image $image.fadeOut(700); }); }); } else { setflag(); //remove navigation removeNavigation(); //if we are on single mode then disperse the thumbs disperse(); } }); //removes the navigation buttons function removeNavigation() { $im_next.stop().animate({'right': '-50px'}, 300); $im_prev.stop().animate({'left': '-50px'}, 300); } //add the navigation buttons function addNavigation() { $im_next.stop().animate({'right': '0px'}, 300); $im_prev.stop().animate({'left': '0px'}, 300); } //User clicks next button (single mode) $im_next.bind('click', function() { if (!flg_click) return; setflag(); ++current; var $next_thumb = $im_wrapper.children('div:nth-child(' + (current + 1) + ')'); if ($next_thumb.length > 0) { var image_src = $next_thumb.find('img').attr('src').replace('/thumbs', ''); var arr = Array.shuffle(positionsArray.slice(0)); $thumbs.each(function(i) { //we want to change each divs background image //on a different point of time var t = $(this); setTimeout(function() { t.css({ 'background-image': 'url(' + image_src + ')' }); if (i == nmb_thumbs - 1) setflag(); }, arr.shift() * 20); }); } else { setflag(); --current; return; } }); //User clicks prev button (single mode) $im_prev.bind('click', function() { if (!flg_click) return; setflag(); --current; var $prev_thumb = $im_wrapper.children('div:nth-child(' + (current + 1) + ')'); if ($prev_thumb.length > 0) { var image_src = $prev_thumb.find('img').attr('src').replace('/thumbs', ''); var arr = Array.shuffle(positionsArray.slice(0)); $thumbs.each(function(i) { var t = $(this); setTimeout(function() { t.css({ 'background-image': 'url(' + image_src + ')' }); if (i == nmb_thumbs - 1) setflag(); }, arr.shift() * 20); }); } else { setflag(); ++current; return; } }); //on windows resize call the disperse function $(window).smartresize(function() { removeNavigation() disperse(); }); //function to shuffle an array Array.shuffle = function(array) { for ( var j, x, i = array.length; i; j = parseInt(Math.random() * i), x = array[--i], array[i] = array[j], array[j] = x ) ; return array; }; }); </script> </body> </html>