flow.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>镜像站@流加载 - 在线演示 - Layui</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <script>
  13. ;!function(){self!==parent&&(location.href="http://www.baidu.com/")}();
  14. </script>
  15. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css?t=1632428048260" media="all">
  16. <link rel="stylesheet" href="/public/static/css/global.css" tppabs="http://res.layui.com/static/css/global.css?t=1632428048260-19" media="all">
  17. <style>
  18. .flow-default{width: 600px; height: 400px; overflow: auto; font-size: 0;}
  19. .flow-default li{display: inline-block; margin: 0 5px; font-size: 14px; width: 48%; margin-bottom: 10px; height: 100px; line-height: 100px; text-align: center; background-color: #eee;}
  20. .flow-default img{width: 100%; height: 100%;}
  21. .site-demo-flow{width: 600px; height: 300px; overflow: auto; text-align: center;}
  22. .site-demo-flow img{width: 40%; height: 200px; margin: 0 2px 5px 0; border: none;}
  23. </style>
  24. </head>
  25. <body>
  26. <div class="layui-layout layui-layout-admin">
  27. <div class="layui-header header header-demo" autumn>
  28. <div class="layui-fluid">
  29. <a class="logo" href="../index.html" tppabs="http://www.layui.com/">
  30. <img src="/public/static/images/layui/logo.png" tppabs="http://res.layui.com/static/images/layui/logo.png" alt="layui">
  31. </a>
  32. <div class="layui-form layui-hide-xs component" lay-filter="LAY-site-header-component"></div>
  33. <div class="layui-hide-xs site-notice"></div>
  34. <ul class="layui-nav" id="LAY_NAV_TOP">
  35. <li class="layui-nav-item ">
  36. <a href="../doc/index.html" tppabs="http://www.layui.com/doc/">文档</a>
  37. </li>
  38. <li class="layui-nav-item layui-this">
  39. <a href="index.html" tppabs="http://www.layui.com/demo/">示例</a>
  40. </li>
  41. <li class="layui-nav-item">
  42. <a href="javascript:;">
  43. <!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>-->
  44. 周边
  45. </a>
  46. <dl class="layui-nav-child layui-nav-child-c">
  47. <dd class="layui-hide-sm layui-show-xs" lay-unselect>
  48. <a href="https://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">问题反馈</a>
  49. <hr>
  50. </dd>
  51. <dd lay-unselect><a href="../alone.html" tppabs="http://www.layui.com/alone.html" target="_blank" lay-unselect>独立组件</a></dd>
  52. <dd lay-unselect><a href="../../fly.layui.com/extend/index.html" target="_blank">扩展组件</a></dd>
  53. </dl>
  54. </li>
  55. <li class="layui-nav-item layui-hide-xs">
  56. <a href="http://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">反馈</a>
  57. </li>
  58. </ul>
  59. </div>
  60. </div>
  61. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  62. <!--[if lt IE 9]>
  63. <script src="../../other/html5shiv/r29/html5.min.js" tppabs="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  64. <script src="../../other/respond.js/1.4.2/respond.min.js" tppabs="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  65. <![endif]-->
  66. <div class="layui-side layui-bg-black">
  67. <div class="layui-side-scroll">
  68. <ul class="layui-nav layui-nav-tree site-demo-nav">
  69. <li class="layui-nav-item layui-nav-itemed">
  70. <a class="javascript:;" href="javascript:;">演示</a>
  71. <dl class="layui-nav-child">
  72. <dd>
  73. <a href="index.html" tppabs="http://www.layui.com/demo/">调试预览</a>
  74. </dd>
  75. </dl>
  76. </li>
  77. <li class="layui-nav-item layui-nav-itemed">
  78. <a class="javascript:;" href="javascript:;">布局</a>
  79. <dl class="layui-nav-child">
  80. <dd class="">
  81. <a href="grid.html" tppabs="http://www.layui.com/demo/grid.html">栅格</a>
  82. </dd>
  83. <dd class="">
  84. <a href="admin.html" tppabs="http://www.layui.com/demo/admin.html">框架</a>
  85. </dd>
  86. </dl>
  87. </li>
  88. <li class="layui-nav-item layui-nav-itemed">
  89. <a class="javascript:;" href="javascript:;">基本元素</a>
  90. <dl class="layui-nav-child">
  91. <dd class="">
  92. <a href="button.html" tppabs="http://www.layui.com/demo/button.html">按钮</a>
  93. </dd>
  94. <dd class="">
  95. <a href="form.html" tppabs="http://www.layui.com/demo/form.html">表单</a>
  96. </dd>
  97. <dd class="">
  98. <a href="nav.html" tppabs="http://www.layui.com/demo/nav.html">导航 / 面包屑</a>
  99. </dd>
  100. <dd class="">
  101. <a href="menu.html" tppabs="http://www.layui.com/demo/menu.html">基础菜单</a>
  102. </dd>
  103. <dd class="">
  104. <a href="tab.html" tppabs="http://www.layui.com/demo/tab.html">选项卡</a>
  105. </dd>
  106. <dd class="">
  107. <a href="progress.html" tppabs="http://www.layui.com/demo/progress.html">进度条</a>
  108. </dd>
  109. <dd class="">
  110. <a href="panel.html" tppabs="http://www.layui.com/demo/panel.html">面板</a>
  111. </dd>
  112. <dd class="">
  113. <a href="badge.html" tppabs="http://www.layui.com/demo/badge.html">徽章</a>
  114. </dd>
  115. <dd class="">
  116. <a href="timeline.html" tppabs="http://www.layui.com/demo/timeline.html">时间线</a>
  117. </dd>
  118. <dd class="">
  119. <a href="table-element.html" tppabs="http://www.layui.com/demo/table-element.html">静态表格</a>
  120. </dd>
  121. <dd class="">
  122. <a href="anim.html" tppabs="http://www.layui.com/demo/anim.html">动画</a>
  123. </dd>
  124. <dd class="">
  125. <a href="auxiliar.html" tppabs="http://www.layui.com/demo/auxiliar.html">辅助元素</a>
  126. </dd>
  127. </dl>
  128. </li>
  129. <li class="layui-nav-item layui-nav-itemed">
  130. <a class="javascript:;" href="javascript:;">组件示例</a>
  131. <dl class="layui-nav-child">
  132. <dd class="">
  133. <a href="layer.html" tppabs="http://www.layui.com/demo/layer.html">
  134. 弹出层
  135. </a>
  136. </dd>
  137. <dd class="">
  138. <a href="laydate.html" tppabs="http://www.layui.com/demo/laydate.html">
  139. 日期与时间选择
  140. </a>
  141. </dd>
  142. <dd class="">
  143. <a href="table.html" tppabs="http://www.layui.com/demo/table.html">
  144. 数据表格
  145. </a>
  146. </dd>
  147. <dd class="">
  148. <a href="laypage.html" tppabs="http://www.layui.com/demo/laypage.html">
  149. 分页
  150. </a>
  151. </dd>
  152. <dd class="">
  153. <a href="dropdown.html" tppabs="http://www.layui.com/demo/dropdown.html">
  154. 下拉菜单
  155. </a>
  156. </dd>
  157. <dd class="">
  158. <a href="upload.html" tppabs="http://www.layui.com/demo/upload.html">
  159. 文件上传
  160. </a>
  161. </dd>
  162. <dd class="">
  163. <a href="transfer.html" tppabs="http://www.layui.com/demo/transfer.html">
  164. 穿梭框
  165. </a>
  166. </dd>
  167. <dd class="">
  168. <a href="tree.html" tppabs="http://www.layui.com/demo/tree.html">
  169. 树形组件
  170. </a>
  171. </dd>
  172. <dd class="">
  173. <a href="colorpicker.html" tppabs="http://www.layui.com/demo/colorpicker.html">
  174. 颜色选择器
  175. </a>
  176. </dd>
  177. <dd class="">
  178. <a href="slider.html" tppabs="http://www.layui.com/demo/slider.html">
  179. 滑块
  180. </a>
  181. </dd>
  182. <dd class="">
  183. <a href="rate.html" tppabs="http://www.layui.com/demo/rate.html">
  184. 评分
  185. </a>
  186. </dd>
  187. <dd class="">
  188. <a href="carousel.html" tppabs="http://www.layui.com/demo/carousel.html">
  189. 轮播
  190. </a>
  191. </dd>
  192. <dd class="">
  193. <a href="laytpl.html" tppabs="http://www.layui.com/demo/laytpl.html">
  194. 模板引擎
  195. </a>
  196. </dd>
  197. <dd class="">
  198. <a href="layedit.html" tppabs="http://www.layui.com/demo/layedit.html">
  199. 富文本编辑器
  200. </a>
  201. </dd>
  202. <dd class="layui-this">
  203. <a href="flow.html" tppabs="http://www.layui.com/demo/flow.html">
  204. 流加载
  205. </a>
  206. </dd>
  207. <dd class="">
  208. <a href="util.html" tppabs="http://www.layui.com/demo/util.html">
  209. 工具模块
  210. </a>
  211. </dd>
  212. <dd class="">
  213. <a href="code.html" tppabs="http://www.layui.com/demo/code.html">
  214. 文本行修饰
  215. </a>
  216. </dd>
  217. </dl>
  218. </li>
  219. <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
  220. </ul>
  221. </div>
  222. </div>
  223. <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
  224. <ul class="layui-tab-title site-demo-title">
  225. <li class="layui-this">预览</li>
  226. <li>查看代码</li>
  227. <li>帮助</li>
  228. </ul>
  229. <div class="layui-body layui-tab-content site-demo site-demo-body">
  230. <div class="layui-tab-item layui-show">
  231. <div class="layui-main">
  232. <div id="LAY_preview">
  233. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  234. <legend>信息流 - 滚动加载</legend>
  235. </fieldset>
  236. <ul class="flow-default" id="LAY_demo1"></ul>
  237. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  238. <legend>信息流 - 手工加载</legend>
  239. </fieldset>
  240. <ul class="flow-default" style="height: 300px;" id="LAY_demo2"></ul>
  241. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  242. <legend>图片懒加载</legend>
  243. </fieldset>
  244. <div class="site-demo-flow" id="LAY_demo3">
  245. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  246. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  247. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  248. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  249. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  250. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  251. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  252. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  253. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  254. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  255. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  256. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  257. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  258. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  259. <img lay-src="/public/upload/2017_3/168_1488985841996_23077.png" tppabs="https://cdn.layui.com/upload/2017_3/168_1488985841996_23077.png">
  260. </div>
  261. <p style="margin-top: 20px;">
  262. 无论滚动条上滑还是下滑,都只始终加载当前屏的图片(你可以快速拉动滚动条到中间区域,然后再往上滑动试试)
  263. <br>layui 的图片懒加载,除了对滚动条的性能进行了美好的优化,也对图片的「当前屏」进行了高效计算,无惧于任何规模庞大的图片数量!
  264. </p>
  265. </div>
  266. <blockquote class="layui-elem-quote" style="margin-top: 30px;">
  267. 更多我们未能呈现的示例,还有待您在阅读文档、以及不断使用的过程,去深入挖掘。
  268. </blockquote>
  269. <div style="margin: 15px 0 100px; padding-bottom: 100px;">
  270. </div>
  271. </div>
  272. </div>
  273. <div class="layui-tab-item">
  274. <textarea class="layui-border-box site-demo-text site-demo-code" id="LAY_democode" spellcheck="false" readonly>
  275. <!DOCTYPE html>
  276. <html>
  277. <head>
  278. <meta charset="utf-8">
  279. <title>镜像站@Layui</title>
  280. <meta name="renderer" content="webkit">
  281. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  282. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  283. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css" media="all">
  284. <!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
  285. </head>
  286. </textarea>
  287. </div>
  288. <div class="layui-tab-item">
  289. <div class="layui-main">
  290. <p></p>
  291. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  292. <legend>相关</legend>
  293. </fieldset>
  294. <a class="layui-btn layui-btn-normal" href="../doc/modules/flow.html" tppabs="http://www.layui.com/doc/modules/flow.html" target="_blank">流加载文档</a>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. <div class="layui-footer footer footer-demo">
  300. <p>
  301. Copyright &copy; 2021 <a href="../index.html" tppabs="http://www.layui.com/">「本站仅为 layui 文档保留的镜像站点,与官方无关」</a> MIT Licensed</p>
  302. <p>
  303. <a href="../about/disclaimer.html" tppabs="http://www.layui.com/about/disclaimer.html" target="_blank">免责声明</a>
  304. <a href="../about/relatedlinks.html" tppabs="http://www.layui.com/about/relatedlinks.html" target="_blank">友链</a>
  305. <a href="javascript:;" site-event="weixinmp">公众号</a>
  306. </p>
  307. <div class="site-union">
  308. <p class="site-union-desc">
  309. <span>
  310. </span>
  311. </p>
  312. </div>
  313. </div>
  314. <script>
  315. window.global = {
  316. pageType: 'demo'
  317. ,preview: function(){
  318. var preview = document.getElementById('LAY_preview');
  319. return preview ? preview.innerHTML : '';
  320. }()
  321. };
  322. </script>
  323. <div class="site-tree-mobile layui-hide">
  324. <i class="layui-icon layui-icon-spread-left"></i>
  325. </div>
  326. <div class="site-mobile-shade"></div>
  327. <script src="/public/layui/dist/layui.js" tppabs="http://res.layui.com/layui/dist/layui.js?t=1632428048260" charset="utf-8"></script>
  328. <script>
  329. layui.config({
  330. base: '/public/static/lay/modules/layui/'
  331. ,version: '1632428048260'
  332. }).use('global');
  333. </script>
  334. </div>
  335. <div id="LAY_democodejs">
  336. <script>
  337. layui.use('flow', function(){
  338. var flow = layui.flow;
  339. flow.load({
  340. elem: '#LAY_demo1' //流加载容器
  341. ,scrollElem: '#LAY_demo1' //滚动条所在元素,一般不用填,此处只是演示需要。
  342. ,done: function(page, next){ //执行下一页的回调
  343. //模拟数据插入
  344. setTimeout(function(){
  345. var lis = [];
  346. for(var i = 0; i < 8; i++){
  347. lis.push('<li>'+ ( (page-1)*8 + i + 1 ) +'</li>')
  348. }
  349. //执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
  350. //pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
  351. next(lis.join(''), page < 10); //假设总页数为 10
  352. }, 500);
  353. }
  354. });
  355. flow.load({
  356. elem: '#LAY_demo2' //流加载容器
  357. ,scrollElem: '#LAY_demo2' //滚动条所在元素,一般不用填,此处只是演示需要。
  358. ,isAuto: false
  359. ,isLazyimg: true
  360. ,done: function(page, next){ //加载下一页
  361. //模拟插入
  362. setTimeout(function(){
  363. var lis = [];
  364. for(var i = 0; i < 6; i++){
  365. lis.push('<li><img lay-src="/public/upload/2017_3/168_1488985841996_23077.png?v='+ ( (page-1)*6 + i + 1 ) +'"></li>')
  366. }
  367. next(lis.join(''), page < 6); //假设总页数为 6
  368. }, 500);
  369. }
  370. });
  371. //按屏加载图片
  372. flow.lazyimg({
  373. elem: '#LAY_demo3 img'
  374. ,scrollElem: '#LAY_demo3' //一般不用设置,此处只是演示需要。
  375. });
  376. });
  377. </script>
  378. </div>
  379. </body>
  380. </html>