在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 ...
随机推荐
- dedecms调用日期格式化形式大全
dedecms特有常用的日期格式化函数MyDate() 代码:[field:pubdate function="MyDate('Y-m-d',@me)" /] 样式:2013-08 ...
- Mac OSX安装启动 zookeeper
安装 zookeeper支持brew安装 ➜ ~ brew info zookeeper zookeeper: stable (bottled), HEAD Centralized server fo ...
- checkmysql.sh
#!/bin/sh # add by lxr MYSQL_SOCK="/tmp/mysql.sock" MYSQL_PWD="qq139547" ARGS=1 ...
- day_4.23 简易计算器
''' 简易加减乘除计算器demo 2018-4-23 19:32:49 ''' #1.界面 print("="*50) print(" 欢迎使用计算器v0.1" ...
- python 中 打印及格式化字符串的相关方法
原文 将值转换为字符串 Python 有多种方式将任何值转为字符串: 将它传给 repr() 或 str() 函数. repr() 和 str() 的区别,看几个例子: >>> pr ...
- 【react】---context的基本使用---【巷子】
一.context的理解 很多优秀的React组件都通过Context来完成自己的功能,比如react-redux的<Provider />,就是通过Context提供一个全局态的stor ...
- Flask web开发之路四
jinjia2模板 模板渲染和参数传递 项目结构如下: 主app文件代码: from flask import Flask,render_template app = Flask(__name__) ...
- mysql distinct 后面没有括号
当distinct应用到多个字段的时候,其应用的范围是其后面的所有字段,而不只是紧挨着它的一个字段,而且distinct只能放到所有字段的前面 如下语句是错误的: SELECT country, di ...
- db2命令参数with ur
查询DB2数据库,老遇到select * from XXX with ur, 好奇ur是什么作用(转) DB2中,共有四种隔离级:RS,RR,CS,UR,DB2提供了这4种不同的保护级别来隔离数据. ...
- 洛谷P1040 加分二叉树【记忆化搜索】
题目链接:https://www.luogu.org/problemnew/show/P1040 题意: 某一个二叉树的中序遍历是1~n,每个节点有一个分数(正整数). 二叉树的分数是左子树分数乘右子 ...