<style type="text/css">
* {
margin: 0;
padding: 0;
} .min {
width: 350px;
height: 400px;
overflow: hidden;
} .min ul {
list-style: none;
display: block;
} .min ul li {
height: 30px;
}
</style>
<body>
<div class="min">
<ul>
<li>21212125</li>
<li>12</li>
<li>343</li>
<li>5345</li>
<li>53</li>
<li>435</li>
<li>ert</li>
<li>345</li>
<li>eg</li>
<li>grrrrrr</li>
<li>3453</li>
<li>ret</li>
<li>345</li>
<li>21212125</li>
<li>456</li>
<li>56</li>
<li>rt</li>
<li>67</li>
<li>768</li>
<li>789</li>
<li>dfg</li>
<li>789</li>
<li>21212gggggg125</li>
<li>21212125</li>
<li>789</li>
<li>eeqqqqqqqq</li>
<li>789</li>
<li>gf</li>
<li>ttgg</li>
<li>sdf</li>
<li>789</li>
<li>21212125</li>
<li>dgdgdgd</li>
<li>90</li>
<li>21212125</li>
<li>-90</li>
<li>21212125</li>
<li>21212125</li>
<li>2121902125</li>
<li>90-</li>
<li>21212125</li>
<li>end</li>
<li>gf</li>
<li>ttgg</li>
<li>sdf</li>
<li>789</li>
<li>21212125</li>
<li>dgdgdgd</li>
<li>90</li>
<li>21212125</li>
<li>-90</li>
<li>21212125</li>
<li>21212125</li>
<li>2121902125</li>
<li>90-</li>
<li>21212125</li>
<li>end</li>
<li>gf</li>
<li>ttgg</li>
<li>sdf</li>
<li>789</li>
<li>21212125</li>
<li>dgdgdgd</li>
<li>90</li>
<li>21212125</li>
<li>-90</li>
<li>21212125</li>
<li>21212125</li>
<li>2121902125</li>
<li>90-</li>
<li>21212125</li>
<li>end</li>
<li>gf</li>
<li>ttgg</li>
<li>sdf</li>
<li>789</li>
<li>21212125</li>
<li>dgdgdgd</li>
<li>90</li>
<li>21212125</li>
<li>-90</li>
<li>21212125</li>
<li>21212125</li>
<li>2121902125</li>
<li>90-</li>
<li>21212125</li>
<li>end</li>
<li>gf</li>
<li>ttgg</li>
<li>sdf</li>
<li>789</li>
<li>21212125</li>
<li>dgdgdgd</li>
<li>90</li>
<li>21212125</li>
<li>-90</li>
<li>21212125</li>
<li>21212125</li>
<li>2121902125</li>
<li>90-</li>
<li>21212125</li>
<li>end</li>
<li>gf</li>
<li>ttgg</li>
<li>sdf</li>
<li>789</li>
<li>21212125</li>
<li>dgdgdgd</li>
<li>90</li>
<li>21212125</li>
<li>-90</li>
<li>21212125</li>
<li>21212125</li>
<li>2121902125</li>
<li>90-</li>
<li>21212125</li>
<li>end9999999999999</li>
</ul>
</div>
</body>

  

    <script>
$.fn.touchEvn = function () { return this.each(function () {
var $this = $(this);
var $touchtarge = $this.children('ul');
var _ = this;
_.startY = 0;
//最高
_.maxHeight = $touchtarge[0].scrollHeight - $this.height();
_.StartSpanTime = undefined;
_.LastTop = 0;
$touchtarge.on('touchstart', function (e) {
_.startY = event.targetTouches[0].pageY;
_.StartSpanTime = event.timeStamp; }).on('touchmove', function (e) {
$(this).css({ 'transition': 'none' });
//移动的长度
var len = _.startY - event.targetTouches[0].pageY;
//最终的长度
len = (_.LastTop + len) * -1;
$(this).css('marginTop', len); }).on('touchend', function (e) {
//最终停留的位置
_.LastTop = _.LastTop + (_.startY - event.changedTouches[0].pageY);
$(this).css({ 'transition': 'margin 1s', 'transition-timing-function': 'cubic-bezier(0.1,0.3,0.5,1)' });
if (_.LastTop < 0) {
_.LastTop = 0;
$(this).css('marginTop', _.LastTop);
} else if (_.LastTop > _.maxHeight) {
_.LastTop = _.maxHeight;
$(this).css('marginTop', _.LastTop * -1);
}
else {
//减速行驶
var endLen = _.checkSpeen(event.timeStamp - _.StartSpanTime, _.startY - event.changedTouches[0].pageY);
_.LastTop = _.LastTop + endLen;
$(this).css('marginTop', _.LastTop * -1);
}
}).on('transitionend',function(){
          if (_.LastTop < 0) {
_.LastTop = 0;
$(this).css('marginTop', _.LastTop);
} else if (_.LastTop > _.maxHeight) {
_.LastTop = _.maxHeight;
$(this).css('marginTop', _.LastTop * -1);
}
          });

                //计算减速行驶距离
_.checkSpeen = function (t, s, maxlen) {
var v = s / t;
//惯性距离
var len = 800 * v / 11;
if (len > maxlen) {
return maxlen;
}
else {
return len;
}
} });
} $('.min').touchEvn();
</script>

  

最新文章

  1. iOS小Tip之查看FPS
  2. __attribute__((packed))作用
  3. 开发 web 桌面类程序几个必须关注的细节
  4. php生成对象的研究
  5. 蓝牙BLE MTU规则与约定
  6. 配置apache以fastcgi运行php
  7. WPF 之 布局(二)
  8. Maven最佳实践:管理依赖
  9. jenkis编译报错:需要class,interface或enum
  10. asp.net中为什么修改了配置文件后我们不需要重启IIS
  11. @CacheEvict(value = { &quot;&quot; })
  12. CSS传统布局之布局模型
  13. 背景图片蒙上一层颜色(背景图片无法用rgba调整透明度!)
  14. 【一本通1329:【例8.2】细胞&amp;&amp;洛谷P1451 求细胞数量】
  15. prometheus监控
  16. postgre中类似oracle的sql%rowcount用法
  17. hdu2602 Bone Collector 01背包
  18. jQuery AJAX方法 前台往后台传数据
  19. bzoj1911 [Apio2010]特别行动队commando
  20. python使用关键字爬取url

热门文章

  1. 2.RabbitMQ Window环境安装
  2. 20140402 cmake编译错误原因 同时装了vs2010和vs2012
  3. jdk源码阅读
  4. python子线程退出
  5. Unity开发一些实用的提高效率的技巧
  6. range和arange
  7. Git 获取项目git clone
  8. Java 多线程 - 锁的类型
  9. 配置文件一spring-mvc.xml
  10. 2019云栖大会开幕,5G边缘计算成首日焦点