webapp 开发之iScroll 学习
demo.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Document</title>
<script src="lib/jquery.js"></script>
<script src="lib/iScroll.js"></script>
<script src="js/demo8.js"></script>
<style>
/******************reset****************************/
body{font-family: 'Microsoft Yahei';background: #eee;}
*{margin:0;padding: 0;}
h1,h2,h3,h4,h5,h6{font-size: 100%;font-weight: normal;font-style: normal;}
ul li{list-style: none;}
/*****************common*****************************/
.mb20{margin-bottom: 20px;}
.clearfix{*zoom:1;}
.clearfix:before,
.clearfix:after{display: table;line-height: 0;content: '';}
.clearfix:after{clear: both;} /******************layout****************************/
.header{position: absolute;top: 0;height: 30px;line-height: 1.5;text-align: center;width: 100%;background: brown;color: white;}
.section{position: absolute;top: 30px;bottom: 30px;overflow: auto;width: 100%;}
.footer{position: absolute;bottom: 0;height: 30px;line-height: 1.5;text-align: center;width: 100%;background: brown;color: white;}
.app-wrapper{height: 100%;} /**
* 滚动图片
*/
.prod-scro-list{background: #fff;padding: 10px;}
.prod-wrapper{width: 300px;background: pink;margin: 0 auto;}
.prod-wrapper .prod-container{width: 1200px;}
.prod-wrapper .prod-container ul {}
.prod-wrapper .prod-container ul li{width: 280px;height: 100px;padding: 10px;float: left;} .scro-nav-bar {width: 100px;margin: 0 auto;}
.scro-nav-bar ul {}
.scro-nav-bar ul li{float: left;width: 23px;text-align: center;display: block;}
.scro-nav-bar ul li.active{background: brown;color: white;}
/**
* 产品详情介绍
*/
.prod-detail-intr{background: #fff;}
.prod-detail-intr article{padding: 20px;} /**
* 产品规格
*/
.prod-format{background: #fff;padding: 10px;}
.prod-format-wrapper{overflow: hidden;width: 300px;background: pink;margin: 0 auto;}
.prod-format-wrapper .prod-format-list{overflow: hidden;width: 900px;}
.prod-format-wrapper .prod-format-list ul{}
.prod-format-wrapper .prod-format-list ul li{width: 280px;height: 100px;padding: 10px;float: left;} nav.prod-format-nav-bar{}
nav.prod-format-nav-bar ul {width: 250px;margin: 0 auto;}
nav.prod-format-nav-bar ul li {float: left;width: 80px;text-align: center;display: block;}
nav.prod-format-nav-bar ul li.active{background: brown;color: white;}
</style>
</head>
<body>
<header class="header"><h1>Header</h1></header>
<section class="section">
<div id="app-wrapper" class="app-wrapper">
<div class="app-container">
<div class="prod-scro-list mb20">
<div id="prod-wrapper" class="prod-wrapper">
<div class="prod-container">
<ul class="clearfix">
<li>this is prod 1 pic</li>
<li>this is prod 2 pic</li>
<li>this is prod 3 pic</li>
<li>this is prod 4 pic</li>
</ul>
</div>
</div>
<nav class="scro-nav-bar">
<ul class="clearfix">
<li class="active">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</nav>
</div>
<div class="prod-detail-intr mb20">
<article>
<h1>this is prod title</h1>
<p>this is introduction paragraph!</p>
</article>
</div>
<div class="prod-format mb20">
<nav class="prod-format-nav-bar">
<ul class="clearfix">
<li class="active">产品名称</li>
<li>产品参数</li>
<li>商品价值</li>
</ul>
</nav>
<div id="prod-format-wrapper" class="prod-format-wrapper">
<div class="prod-format-list">
<ul class="clearfix">
<li>this is format 1</li>
<li>this is format 2</li>
<li>this is format 3</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<footer class="footer"><p>Footer</p></footer>
</body>
</html>
demo6.js
;(function () {
'use strict';
var ProdDetailApp = function () {
var sectScrol = null,
prodScrol = null,
prodFormScrol = null;
this.run = function () {
// console.log('running!');
$(window).load(function () {
sectScrol = new iScroll('app-wrapper');
prodScrol = new iScroll('prod-wrapper', {
snap: true,
momentum: false,
hScrollbar: false,
onScrollEnd: function () {
document.querySelector('.scro-nav-bar ul li.active').className = '';
document.querySelector('.scro-nav-bar ul li:nth-child('+(this.currPageX+1)+')').className='active';
}
});
prodFormScrol = new iScroll('prod-format-wrapper', {
snap: true,
momentum: false,
hScrollbar: false,
onScrollEnd: function () {
document.querySelector('.prod-format-nav-bar ul li.active').className = '';
document.querySelector('.prod-format-nav-bar ul li:nth-child('+(this.currPageX+1)+')').className='active';
}
});
});
$(document).delegate('.prod-format-nav-bar ul li', 'click', navScrolAction);
function navScrolAction (e) {
var $this = $(e.target),
index = $this.index();
prodFormScrol.scrollToPage(index, 1);
}
}
}
var prodDetailApp = new ProdDetailApp();
prodDetailApp.run();
}());
webapp 开发之iScroll 学习的更多相关文章
- IOS开发之XCode学习011:UISwitch控件
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.定义UIswitch控件,添加UIswitc ...
- 移动开发之h5学习大纲
移动开发学习形式:授课.自学 1.html5 css3 htm5shiv.js response.js 2.流式布局 自适应布局 盒模型 弹性盒模型 响应式布局3.iscroll swiper boo ...
- iOS开发之git学习
本人是参考廖雪峰的git学习的.他写的非常详细,我在这里就是把我学习中的总结以及碰到的坑写出来. /* 初始化git仓库:git init */ /* 添加文件到git仓库 */ 分两步: 第一步:追 ...
- IOS开发之XCode学习012:Slider和ProgressView
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.定义UISlider和UIProgressV ...
- IOS开发之XCode学习010:定时器和视图对象
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.通过点击"启动定时器"按钮 ...
- IOS开发之XCode学习009:UIViewController使用
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 通过点击屏幕事件,调用ViewController ...
- IOS开发之XCode学习008:UIViewController基础
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 红色框选部分用A代替,AppDelegate类在程序框架启动时,如果在i ...
- IOS开发之XCode学习007:UIWindow对象
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm #import "AppDelegate.h" @i ...
- IOS开发之XCode学习013:步进器和分栏控件
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.定义UIStepper和UISegmente ...
随机推荐
- 土地购买 usaco 斜率优化
看这道题的时候,感觉很难,因为数据范围比较大,很难dp: 后来想到了[书柜的尺寸]这道题,也是一道dp,曾经看了那道题的题解而深有启发: 这道题每组的付费只与这一组长宽的最大值有关,也就是说要分组,一 ...
- [Shoi2007]Bookcase 书柜的尺寸 dp
这道dp算是同类型dp中比较难的了,主要难点在于设置状态上: 如果像平时那样设置,必定爆空间没商量: 下面是一种思路: 先把输入进来的数据按h从大到小排序,这样就可以大大减少状态数, 然后设f[i][ ...
- IP分片浅析
在TCP/IP分层中,数据链路层用MTU(Maximum Transmission Unit,最大传输单元)来限制所能传输的数据包大小,MTU是指一次传送的数据最大长度,不包括数据链路层数据帧的帧头, ...
- HDOJ 2069 Coin Change(母函数)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- PHPStorm+PHP5.6+WIN7+IIS7
文件下载 以下为参考网址,如无法打开或变动,请自行搜索,获取最新版本文件请行搜索 PHP Manager:http://www.iis.net/downloads/community/2010/09/ ...
- jquery easyui tab加载内容的几种方法
转:http://my.oschina.net/u/2331760/blog/391937?fromerr=saqeoxxB jQuery Easyui 的tabs插件有两种方式加载某个tab(标签页 ...
- 彻底理解js中this的指向
首先必须要说的是,this的指向在函数定义的时候是确定不了的,只有函数执行的时候才能确定this到底指向谁,实际上this的最终指向的是那个调用它的对象(这句话有些问题,后面会解释为什么会有问题,虽然 ...
- poj 2723
Get Luffy Out Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7295 Accepted: 2778 Des ...
- procedure can't return a result set in the given context
调用存储过程失败!出现如下错误:PROCEDURE ipbx.qu_ery can't return a result set in the given context, ipbx是数据库, qu_e ...
- MySQL 5.1参考手册
目录 前言 1. 一般信息 1.1. 关于本手册 1.2. 本手册采用的惯例 1.3. MySQL AB概述 1.4. MySQL数据库管理系统概述 1.4.1. MySQL的历史 1.4.2. My ...