另一篇 :https://www.cnblogs.com/bndy/articles/1692164.html

index.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>

<style>

#inp {

width: 100%;

height: 30%;

position: absolute;

left: 0;

bottom: 0;

background-color: antiquewhite;

}

</style>

</head>

<body>

<div id="inp"></div>

<script src="./index.js"></script>

</body>

</html>

index.js 中:

function load (){

document.addEventListener('touchstart',touch, false);

document.addEventListener('touchstart',touch, false);

document.addEventListener('touchend',touch, false);

function touch (event){

var event = event || window.event;

var oInp = document.getElementById("inp");

switch(event.type){

case "touchstart":

oInp.innerHTML = "Touch started (" + event.touches[0].clientX + "," + event.touches[0].clientY + ")";

// oInp.style.cssText="height: event.touches[0].clientY;"

break;

case "touchend":

oInp.innerHTML = "<br>Touch end (" + event.changedTouches[0].clientX + "," + event.changedTouches[0].clientY + ")";

console.log(event.changedTouches[0].clientY,1111);

// if(event.changedTouches[0].clientY > 440) {

//     oInp.style.cssText="height: 30%;"

// } else if(event.changedTouches[0].clientY > 220){

//     oInp.style.cssText="height: 60%;"

// } else if(event.changedTouches[0].clientY < 220){

//     oInp.style.cssText="height: 90%;"

// }

console.log(window.screen.availHeight*0.33,3333333333);

if(event.changedTouches[0].clientY > (window.screen.availHeight*0.66)) {

oInp.style.cssText="height: 30%;"

} else if(event.changedTouches[0].clientY > (window.screen.availHeight*0.33)){

oInp.style.cssText="height: 60%;"

} else if(event.changedTouches[0].clientY < (window.screen.availHeight*0.33)){

oInp.style.cssText="height: 90%;"

}

break;

case "touchmove":

event.preventDefault();

oInp.innerHTML = "<br>Touch moved (" + event.touches[0].clientX + "," + event.touches[0].clientY + ")";

break;

}

}

}

window.addEventListener('load',load, false);

console.log('屏幕高度:',window.screen.availHeight);

js 实现上下滑动面板 touchstart touchstart touchend相关推荐

  1. touchstart ,touchmove, touchend 页面随手指滑动

    <pre style="font-family: 'Courier New'; background-color: rgb(255, 255, 255);"><s ...

  2. 移动端事件touchstart touchmove touchend 动画事件 过渡事件

    在移动端新增了touch事件,因为手指的行为叫做"触摸", 鼠标的行为叫做"点击" 但是它仍然支持点击事件,有300ms的延迟,检测是否双击 移动端的三个事件 ...

  3. 移动端的touchstart,touchmove,touchend事件中的获取当前touch位置

    前提:touchstart,touchmove,touchend这三个事件可以通过原生和jq绑定. 原生:document.querySelector("#aa").addEven ...

  4. JavaScript touch 事件 touchstart touchmove touchend

    JavaScript touch 事件 touchstart touchmove touchend MDN 官方文档: https://developer.mozilla.org/en-US/docs ...

  5. js的左右滑动触屏事件

    js的左右滑动触屏事件,主要有三个事件:touchstart,touchmove,touchend.这三个事件最重要的属性是 pageX和 pageY,表示X,Y坐标. touchstart在触摸开始 ...

  6. 纯JS实现左右滑动布局和滑动

    <!DOCTYPE html> <html> <head><meta charset=utf-8><meta name=keywords cont ...

  7. JS左侧竖向滑动菜单

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>JS左侧竖向滑动菜单 - w ...

  8. js 简单的滑动教程(四)

    作者:Lellansin 转载请标明出处,谢谢 在大概的了解滑动的基本原理和怎么去实现之后,现在我们将更深入的去讨论js的滑动. 相信细心的朋友应该已经发现了,在本教程前几篇中的代码,还存在着bug, ...

  9. 下滑加载更多js_vue.js怎么实现滑动到底部加载更多数据效果?

    vue.js怎么实现滑动到底部加载更多数据效果?下面本篇文章给大家简单介绍一下vue实现滑动到底部加载更多效果.有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助. 本文实例为大家分享了v ...

最新文章

  1. 《团队合作大坑合集》
  2. 阿里云重磅发布云原生裸金属方案:裸金属+容器,解锁云计算的新方式
  3. 数制转换itoa atoi int转字符串 字符串转int string转int int转string
  4. JQuery中this指向
  5. js笔记(五)文档对象模型DOM
  6. 前端学习(2605):增加响应头和option的关系
  7. c语言代码可以python运行吗_c语言如何运行python脚本
  8. java服务器端socket,java 服务器端socket
  9. dgl._ffi.base.DGLError: Cannot assign node feature “n_feat“ on device cuda:0 to a graph on device
  10. python小程序_小会计的实用Python小程序(三):人民币大写金额转换器
  11. Linux 目录简要结构认识
  12. C 语言中的指针和内存泄漏
  13. 针对binlog MIXED格式对表的增删改统计分析
  14. 使用 Calibre Web 搭建私人电子图书馆
  15. 独家:海尔消金“重仓”医美,月放款量惊人
  16. 大话成像之《图像质量测试测量与国际标准》课程
  17. java 微博第三方登录_Connect/login - 微博API
  18. java将excel转base64_将图片的base64 代码转换为 图片(jpg)
  19. python判断能否组成三角形_【python+任意输入3个数+判断能否组成三角形】 - #1
  20. JAVA修练秘籍第五章《卧薪尝胆》

热门文章

  1. iview template模式_iview render的使用
  2. DELL C6100 U盘安装centos 6.5教程
  3. 【产品细节一】指纹解锁
  4. 0011 难以取悦的姑娘
  5. Python---入门 ( 一 到 四 Unit )(1)
  6. python中出现变量前后带下划线的是什么意思
  7. 基于SSM婚纱摄影网站
  8. react入门-点击变色
  9. html引入stylus,Web使用Pug与Stylus
  10. 西工大计算机博士好难毕业,老牌985西北工业大学的毕业生最后怎样了?1/3留陕西,月薪7000+...