主攻ASP.NET MVC4.0之重生:上下滑动屏幕动态加载数据
2013-10-12 17:06
543 查看
@{ ViewBag.Title = "Index"; } <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <title>摩卡新闻</title> <script src="~/Content/js/iscroll.js"></script> <script type="text/javascript"> var myScroll, pullDownEl, pullDownOffset, pullUpEl, pullUpOffset, generatedCount = 0; function pullDownAction() { setTimeout(function () { // <-- Simulate network congestion, remove setTimeout from production! var el, li, i; el = document.getElementById('thelist'); for (i = 0; i < 3; i++) { li = document.createElement('li'); li.innerText = '向上更新内容' + (++generatedCount); el.insertBefore(li, el.childNodes[0]); } myScroll.refresh(); // Remember to refresh when contents are loaded (ie: on ajax completion) }, 1000); // <-- Simulate network congestion, remove setTimeout from production! } function pullUpAction() { setTimeout(function () { // <-- Simulate network congestion, remove setTimeout from production! var el, li, i; el = document.getElementById('thelist'); for (i = 0; i < 3; i++) { li = document.createElement('li'); li.innerText = '向下更新内容 ' + (++generatedCount); el.appendChild(li, el.childNodes[0]); } myScroll.refresh(); // Remember to refresh when contents are loaded (ie: on ajax completion) }, 1000); // <-- Simulate network congestion, remove setTimeout from production! } function loaded() { pullDownEl = document.getElementById('pullDown'); pullDownOffset = pullDownEl.offsetHeight; pullUpEl = document.getElementById('pullUp'); pullUpOffset = pullUpEl.offsetHeight; myScroll = new iScroll('wrapper', { useTransition: true, topOffset: pullDownOffset, onRefresh: function () { if (pullDownEl.className.match('loading')) { pullDownEl.className = ''; pullDownEl.querySelector('.pullDownLabel').innerHTML = '↓往下拉,加油!!!'; } else if (pullUpEl.className.match('loading')) { pullUpEl.className = ''; pullUpEl.querySelector('.pullUpLabel').innerHTML = '↑往上拉,加油!!!'; } }, onScrollMove: function () { if (this.y > 5 && !pullDownEl.className.match('flip')) { pullDownEl.className = 'flip'; pullDownEl.querySelector('.pullDownLabel').innerHTML = '↑松开可以刷新'; this.minScrollY = 0; } else if (this.y < 5 && pullDownEl.className.match('flip')) { pullDownEl.className = ''; pullDownEl.querySelector('.pullDownLabel').innerHTML = '↑松开可以刷新'; this.minScrollY = -pullDownOffset; } else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) { pullUpEl.className = 'flip'; pullUpEl.querySelector('.pullUpLabel').innerHTML = '↓松开可以刷新'; this.maxScrollY = this.maxScrollY; } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) { pullUpEl.className = ''; pullUpEl.querySelector('.pullUpLabel').innerHTML = '↓松开可以刷新'; this.maxScrollY = pullUpOffset; } }, onScrollEnd: function () { if (pullDownEl.className.match('flip')) { pullDownEl.className = 'loading'; pullDownEl.querySelector('.pullDownLabel').innerHTML = '正在加载中...'; pullDownAction(); // Execute custom function (ajax call?) } else if (pullUpEl.className.match('flip')) { pullUpEl.className = 'loading'; pullUpEl.querySelector('.pullUpLabel').innerHTML = '正在加载中...'; pullUpAction(); // Execute custom function (ajax call?) } } }); setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800); } document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false); </script> <link href="~/Content/css/iscroll.css" rel="stylesheet" /> </head> <body> <div id="header"><a href="#">摩卡新闻</a></div> <div id="wrapper"> <div id="scroller"> <div id="pullDown"> <span class="pullDownIcon"></span><span class="pullDownLabel">↓往下拉,加油!!!</span> </div> <ul id="thelist"> <li>宁波电视台回应卫星车在余姚被砸 </li> <!--文章中含有违禁内容 以下内容屏蔽 --> </ul> <div id="pullUp"> <span class="pullUpIcon"></span><span class="pullUpLabel">↑往上拉,查看更多!!!</span> </div> </div> </div> <div id="footer"><a href="#">Copyright 2013 摩卡移动网 m.moka.com </a></div> </body> </html>
相关文章推荐
- js/jq控制页面动态加载数据,滑动滚动条自动加载事件
- android左右滑动加载分页以及动态加载数据
- android左右滑动加载分页以及动态加载数据
- android左右滑动加载分页以及动态加载数据
- Web App 向上滑动动态加载数据 2015-06-11 09:36 20人阅读 评论(0) 收藏
- [JS前端开发] js/jquery控制页面动态加载数据 滑动滚动条自动加载事件
- Web App 向上滑动动态加载数据
- android左右滑动加载分页以及动态加载数据
- android左右滑动加载分页以及动态加载数据
- js移动端滑动一个屏幕再加载新的数据以及ajax同步请求
- js/jquery控制页面动态加载数据 滑动滚动条自动加载事件--转他人的
- swiper 解决动态加载数据滑动失效
- setOnScrollListener实现网络请求上下滑动加载数据
- [JS前端开发] js/jquery控制页面动态加载数据 滑动滚动条自动加载事件
- Android ViewPager动态向前向后加载数据,自定义viewPager滑动速度
- 解决swiper动态数据加载在移动端下左右滑动不好使?
- h5微网页向上滑动屏幕加载跟多数据例子(原生js)
- 解决swiper动态数据加载在移动端下左右滑动不好使?
- swiper 解决动态加载数据滑动失效的问题
- js/jquery控制页面动态加载数据 滑动滚动条自动加载事件的方法