在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 ...
随机推荐
- Java知多少(58)线程Runnable接口和Thread类详解
大多数情况,通过实例化一个Thread对象来创建一个线程.Java定义了两种方式: 实现Runnable 接口: 可以继承Thread类. 下面的两小节依次介绍了每一种方式. 实现Runnable接口 ...
- SpringBoot------Servlet3.0的注解自定义原生Servlet
1.添加需要使用的依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w ...
- sklearn数据预处理
一.standardization 之所以标准化的原因是,如果数据集中的某个特征的取值不服从标准的正太分布,则性能就会变得很差 ①函数scale提供了快速和简单的方法在单个数组形式的数据集上来执行标准 ...
- MyEclipse-10.0下Struts2.1+Spring3.0+Hibernate3.3整合过程
新建web project: 命名为SSH,做如下设置: 新建后的工程目录如下: 然后开始添加SSH框架,这里我按照struts-spring-hibernate顺序进行添加. 首先添加struts2 ...
- C语言结构体初始化(转载)
<代码大全>建议在变量定义的时候进行初始化,但是很多人,特别是新人对结构体或者结构体数组定义是一般不会初始化,或者不知道怎么初始化. 1.初始化 typedef struct _TEST_ ...
- C++文件流操作
#include <iostream> #include <fstream> #include<iostream> using namespace std; int ...
- 更新docker时间-需要重启docker
更新docker时间:1.docker run -d -v /etc/localtime:/etc/localtime:ro [IMAGE] 2.重启,docker-compose up -d 3.d ...
- db2 reorg(转)
DB2 reorg RUNSTATS: db2 connect to rmdb11 user rmadmin using rmadmin 对所有用户表执行runstats(reorgchk加updat ...
- weblogic启动项目,设置内容、设置的数据源链接不生效
昨天坑自己了一把,把weblogic的数据库连接方式由jdbc改成了jndi,然后不生效,还是走之前jdbc的连接地址. 因为数据库用户之前权限有问题,所以一直纠结于这个地方,忘记了缓存的原因. 后来 ...
- [No0000DF]C# ZipFileHelper ZIP类型操作,压缩解压 ZIP 类封装
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using Sys ...