<!DOCTYPE html> <html> <head> <!-- meta- --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <title>My App</title> <!-- framework7 , id, --> <link id="pagestyle" rel="stylesheet" href="lib/framework7.css"> <!-- --> <link rel="stylesheet" href="css/app.css"> </head> <body> <!-- statusbar-overlay --> <div class="statusbar-overlay"></div> <!-- panel --> <div class="panel-overlay"></div> <!-- reveal --> <div class="panel panel-left panel-reveal"> </div> <!-- , views --> <div class="views"> <!-- , view-main --> <div class="view view-main"> <!-- , --> <div class="navbar theme-white"> </div> <!-- , navbar toolbar --> <div class="pages navbar-through toolbar-through"> <!-- data-page , --> <div data-page="index" class="page"> <div class="page-content"> </div> </div> </div> <!-- --> <div class="toolbar"> <div class="toolbar-inner"> </div> </div> </div> </div> <!-- framework7 --> <script type="text/javascript" src="lib/framework7.js"></script> <script type="text/javascript" src="app.js"></script> </body> </html>
<div class="page-content"> </div>
<div class="page-content pull-to-refresh-content"> <div class="pull-to-refresh-layer"> <div class="preloader"></div> <div class="pull-to-refresh-arrow"></div> </div> </div>
<div class="list-block media-list"><ul> </ul></div>
<div class="list-block virtual-list media-list"> </div>
<div class="page-content pull-to-refresh-content infinite-scroll" data-distance="100"> <div class="pull-to-refresh-layer"> <div class="preloader"></div> <div class="pull-to-refresh-arrow"></div> </div> <div class="list-block virtual-list media-list"></div> <div class="infinite-scroll-preloader"> <div class="preloader"></div> </div> </div>
<div class="list-block left-menu"> <div class="row theme-white" style="width:90%;margin-left: auto;margin-right: auto;"> <div class="col-50"> <a href="#" class="button changestyle" rel="lib/framework7.css">iOS style</a> </div> <div class="col-50"> <a href="#" class="button changestyle" rel="lib/framework7.material.css">Android style</a> </div> </div> </div>
// var myApp = new Framework7({ animateNavBackIcon:true, pushState: true, // , back android modalTitle: "MyApp", modalButtonCancel: "", // Cancel swipePanel: 'left', // }); // ios, back , if (Framework7.prototype.device.os == "ios") myApp.params.pushState = false; // jQuery Dom7, $, , $$, jQuery, var $$ = Dom7; // css , ios material . localStorage, css $$(".changestyle").click(function() { $$("#pagestyle").attr("href",$$(this).attr('rel')); localStorage.setItem("css", $$(this).attr('rel')); return false; }); // css if(localStorage.getItem("css")) { $$("#pagestyle").attr("href",localStorage.getItem("css")); } // var mainView = myApp.addView('.view-main', { dynamicNavbar: true, domCache: true, // scroll position }); // ( Template7) var myList = myApp.virtualList('.list-block.virtual-list', { items: [ { id: 1, title: 'Item 1', picture: 'http://lorempixel.com/88/88/abstract/1' }, { id: 2, title: 'Item 2', picture: 'http://lorempixel.com/88/88/abstract/2' } ], height:44, template: '<li class="contact-item" data-id="{{id}}" >' + '<a href="about.html" class="item-link">' + '<div class="item-content">' + '<div class="item-media"><img src="{{picture}}" width="22"></div>' + '<div class="item-inner">' + '<div class="item-title">{{title}}</div>' + '</div>' + '</div>' + '</a>' + '</li>' }); // , function reloadTable(table, array) { table.items = array; table.update(); } // 20 var itemsArray = []; function firstInitList(text, count) { itemsArray = []; for (var i = 0; i < count; i++ ) { itemsArray.push({ id: i, title: text + ' ' + i, picture: 'http://lorempixel.com/88/88/abstract/' + i }); } } firstInitList("Item", 20); reloadTable(myList, itemsArray); // pull-to-refresh var ptrContent = $$('.pull-to-refresh-content'); ptrContent.on('refresh', function (e) { // 0.5 setTimeout(function () { refreshIt(); }, 500); }); // var authors = ['Beatles', 'Queen', 'Michael Jackson', 'Red Hot Chili Peppers']; function refreshIt() { // 10 Refresh firstInitList("Refresh", 10); myList.deleteAllItems(); myList.appendItems(itemsArray); // 8000 var temparr = []; for(var i = 0; i<8000; i++) { var picURL = 'http://lorempixel.com/88/88/abstract/' + Math.round(Math.random() * 10); var author = authors[Math.floor(Math.random() * authors.length)]; temparr.push({ id: i, title: author, picture: picURL }); } myList.appendItems(temparr); myApp.pullToRefreshDone(); } // infinite-scroll $$('.infinite-scroll').on('infinite', function () { loadMore(); }); // var loading = false; // infinite-scroll' $$('.infinite-scroll-preloader').hide(); function loadMore() { // , if (loading) return; $$('.infinite-scroll-preloader').show(); // 1 setTimeout(function () { for (var i = lastIndex + 1; i <= lastIndex + itemsPerLoad; i++) { itemsArray.push({ id: i, title: 'Item ' + i, picture: 'http://lorempixel.com/88/88/abstract/1' }); } reloadTable(myList, itemsArray); // , loading = true; }, 1000); }
// infinite-scroll .infinite-scroll-preloader { margin-top:-20px; margin-bottom: 10px; text-align: center; } .infinite-scroll-preloader .preloader { width:34px; height:34px; } // navbar .navbar { border-bottom: none; background: #2196f3; color: #ffffff; } .navbar a.link { color: #ffffff; } // .panel, .left-menu .list-button { background-color: #3f4041; } .left-menu .item-link.list-button { text-align: left; }
Source: https://habr.com/ru/post/257889/
All Articles