在asp.net中使用瀑布流,无限加载
页面中代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="waterfall.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="css/main.css" rel="stylesheet" />
<link href="css/reset.css" rel="stylesheet" /> </head>
<body>
<form id="form1" runat="server">
<div id="container">
<header>
<h1>Wookmark测试</h1>
<p>往下拉,就能看到效果</p>
</header>
<div id="main" role="main">
<ul id="tiles">
<li>
<img src="data:images/image_1.jpg" width="" height="" alt="">
<p>图片描述1</p>
</li>
<li>
<img src="data:images/image_2.jpg" width="" height="" alt="">
<p>图片描述2</p>
</li>
<li>
<img src="data:images/image_3.jpg" width="" height="" alt="">
<p>图片描述3</p>
</li>
<li>
<img src="data:images/image_1.jpg" width="" height="" alt="">
<p>图片描述4</p>
</li>
<li>
<img src="data:images/image_2.jpg" width="" height="" alt="">
<p>图片描述5</p>
</li>
<li>
<img src="data:images/image_3.jpg" width="" height="" alt="">
<p>图片描述6</p>
</li>
<li>
<img src="data:images/image_1.jpg" width="" height="" alt="">
<p>图片描述7</p>
</li>
<li>
<img src="data:images/image_2.jpg" width="" height="" alt="">
<p>图片描述8</p>
</li>
<li>
<img src="data:images/image_3.jpg" width="" height="" alt="">
<p>图片描述9</p>
</li>
<li>
<img src="data:images/image_1.jpg" width="" height="" alt="">
<p>图片描述10</p>
</li>
</ul>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.imagesloaded.js"></script>
<script src="js/jquery.wookmark.js"></script>
<!-- Once the page is loaded, initalize the plug-in. -->
<script type="text/javascript">
(function ($) {
$('#tiles').imagesLoaded(function () {
var handler = null; // Prepare layout options.
var options = {
autoResize: true, // This will auto-update the layout when the browser window is resized.
container: $('#main'), // Optional, used for some extra CSS styling
offset: , // Optional, the distance between grid items
itemWidth: // Optional, the width of a grid item
}; function applyLayout() {
$('#tiles').imagesLoaded(function () {
// Destroy the old handler
if (handler.wookmarkInstance) {
handler.wookmarkInstance.clear();
} // Create a new layout handler.
handler = $('#tiles li');
handler.wookmark(options);
});
} /**
* When scrolled all the way to the bottom, add more tiles.
*/
function onScroll(event) {
// Check if we're within 100 pixels of the bottom edge of the broser window.
var winHeight = window.innerHeight ? window.innerHeight : $(window).height(); // iphone fix
var closeToBottom = ($(window).scrollTop() + winHeight > $(document).height() - );
//异步请求
if (closeToBottom) {
$.ajax({
type: 'get',
url: 'LoadImages.ashx',
async: 'true',
data: { getPage: page },
success: function (result) {
$('#tiles').append(result);
applyLayout();
InitImage();
page = page + ;
}
}); }
}; // Capture scroll event.
$(window).bind('scroll', onScroll); // Call the layout function.
handler = $('#tiles li');
handler.wookmark(options);
});
})(jQuery); </script>
<script type="text/javascript">
var page = ; function InitImage() { $("#tiles li p").hide();
$("#tiles li").hover(function () {
$(this).children().last().show();
}, function () {
$(this).children().last().hide();
});
} InitImage();
</script>
</form>
</body>
</html>
需要配置的一般处理程序,接收ajax请求
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web; namespace waterfall
{
/// <summary>
/// LoadImages 的摘要说明
/// </summary>
public class LoadImages : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
Random rd = new Random(); int page = int.Parse(context.Request.QueryString["getPage"]);
StringBuilder sb = new StringBuilder();
const string html = "<li><img src=\"images/image_@imgIndex@.jpg\" width=\"200\" height=\"300\"><p>@page@</p></li>";
for (int i = ; i < ; i++)
{
sb.Append(html.Replace("@page@", (page* + i).ToString()).Replace("@imgIndex@",rd.Next(,).ToString()));
}
context.Response.Write(sb.ToString());
} public bool IsReusable
{
get
{
return false;
}
}
}
}
wookmark下载地址:点击这里下载
demo下载:点击这里下载
在asp.net中使用瀑布流,无限加载的更多相关文章
- 瀑布流无限加载infinitescroll插件与masonry插件使用
masonry官网地址http://masonry.desandro.com/,infinitescroll官网地址http://www.infinite-scroll.com/ 无限滚动原理:无限滚 ...
- jQuery瀑布流+无限加载图片
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js实现瀑布流以及加载效果
一.瀑布流是个啥? 瀑布流,是比较流行的一种网站页面布局,视觉表现为参差不齐的多栏布局,随着页面滚动条向下滚动,这种布局还会不断加载数据块并附加至当前尾部. 最早采用瀑布流布局的网站是Pinteres ...
- jQuery8种不同的瀑布流懒加载loading效果
优化图片加载插件jQuery8种不同的瀑布流懒加载loading效果 在线预览 下载地址 实例代码 <ul class="grid effect-1" id="g ...
- asp.net中TreeView的大数据加载速度优化
由于数据量太大,加载树时间很长,所以进行了优化 前台 .aspx <asp:Panel ID="Panel2" runat="server" Height ...
- 基于jquery响应式网站图片无限加载瀑布流布局
分享一款效果非常酷的jQuery瀑布流布局无限加载图片效果.整个页面采用响应式布局,图片采用jQuery.Lazyload延时加载技术,提升整个页面的加载速度.效果图如下: 在线预览 源码下载 实 ...
- jQuery实现无限加载瀑布流特效
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- html中的瀑布流是什么
html中的瀑布流是什么 一.总结 1.瀑布流: 从左往右排列,哪一列现在的总高度最小,就优先排序把item(单元格)放在这一列.这样排完所有的单元格后,可以保证每一列的总高度都相差不大 2.看效果图 ...
- CSS3学习总结——实现瀑布流布局与无限加载图片相册
首先给大家看一下瀑布流布局与无限加载图片相册效果图: 一.pic1.html页面代码如下: <!DOCTYPE html> <html> <head> <me ...
随机推荐
- Spring 自动转配类 在类中使用@Bean 注解进行转配但是需要排除该类说明
在spring中可以使用 @Component @Configuration @Bean(实例化后返回该bean)进行类实例的自动装配. 需求: 排除指定需要自动转配的类. 说明: 1.在以上注解中 ...
- Mac/Linux如何查找应用所安装路径
Linux.Mac中查看某 个软件的安装路径(地址)有时显得非常重要.比如某个文件的快速启动项被删除,或者你要建立快速启动项,或者想删除. 添加安装文件等等,很多地方都要用到查案文件安装路径的命令. ...
- eclipse java ee jsp tomcat Server文件夹给删了,怎么办?
右键 选择属性 选择Switch location 就可以了
- android TV选中时高亮凸显效果
链接: http://pan.baidu.com/s/1pLjAFQ7 密码: xb8g <ignore_js_op> 360手机助手截图0410_18_02_01.png (335.64 ...
- QT下载区
http://download.qt.io/archive/qt/ 下载总网址: http://download.qt.io/ http://mirrors.hust.edu.cn/qtproject ...
- INTERVAL
select sysdate - interval '10' day as "10天前", sysdate - interval '10' hour as " ...
- TransmittableThreadLocal 解决 线程池线程复用 无法复制 InheritableThreadLocal 的问题.
ThreadLoacl,InheritableThreadLocal,原理,以及配合线程池使用的一些坑 TransmittableThreadLocal 原理 之前为了能让InheritableThr ...
- 关于linux下mysql 5.7.x数据库的yum的安装方法
环境介绍>>>>>>>>>>>>>>>>>> 操作系统:Centos 7.1 mysql数据 ...
- for循环将字典添加到列表中出现覆盖前面数据的问题
出现问题: rets = [{'id':1},{"id":2},{"id":3}] context = {} context['count'] = len(re ...
- 3D Slicer 4.7.0 VS 2010 Compile 编译
花了将近一周的时间的,终于在VS2010成功的编译了最新版的3D Slicer 4.7.0,感觉快要崩溃了.Slicer用了20多个外部的库,全都要一起编译,完整编译一次起码要七八个小时,光VS的Ou ...