


html5 touch event realizes sliding up and down the touch screen page (1)_html5 tutorial skills
The recent app project I was working on caused a lot of problems due to the use of overflow: hidden, so I decided to study the touch event of HTML5. It is difficult to find a comprehensive post. Although there are many articles about html5 touch, most of them introduce touch events or very short demos.
A relatively comprehensive small demo of sliding up and down, the code is relatively simple.
The following is the complete code. I have marked several important places in red
- html>
- html lang="en">
- head>
- meta charset="UTF-8">
- meta name="viewport" content="width=device-width,initial-scale=1 user-scalable=0"/>
- title>2014-4-29title>
- style>
- * {margin: 0; padding: 0;}
- #outer{ width:90%; height: 490px; background: #000; margin: auto; overflow: hidden;}
- #inner{width:80%; height: 2000px; background: #f67d42; margin: auto; position:relative; top:0; }
- style>
- script src='jquery-1.9.1.min.js'>script>
- head>
- body>
- div id="spText">div>
- div id="outer">
- div id="inner">
- 123br> 123br> gagbr> afbr> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> yryyrbr> ryrybr> 123br> 123br> 123br> 123br> 123br> sdffbr> fefbr> 123br> hrbr> hrhbr> 5ybr> 123br> erbr> ertbr> 123br> rgdgdgbr> 123br> 123br> 123br> 123br> 123br> 123br> gfgfgfgfgfgfbr> sdsdsdsdsdsdbr> sfbr> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> gdggdgdgbr> 123br> drgdrgdbr> 123br> 123br> 123br> yuyuyuyuyuybr> hjkhjkhkhkhjkhkhbr> kjkjkbr>123br> 123br> gagbr> afbr> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> yryyrbr> ryrybr> 123br> 123br> 123br> 123br> 123br> sdffbr> fefbr> 123br> hrbr> hrhbr> 5ybr> 123br> erbr> ertbr> 123br> rgdgdgbr> 123br> 123br> 123br> 123br> 123br> 123br> gfgfgfgfgfgfbr> sdsdsdsdsdsdbr> sfbr> 123br> 123br> 123br> 123br> 123br> 123br> 123br> 123br> gdggdgdgbr> 123br> drgdrgdbr> 123br> 123br> 123br> yuyuyuyuyuybr> hjkhjkhkhkhjkhkhbr> kjkjkbr>
- div>
- div>
- script>
- var startX, //Coordinates when touched
- startY,
- x, //sliding distance
- y,
- aboveY=0; //Set a global variable to record the position of the last internal block slide
- var inner=document.getElementById("inner");
- function touchSatrt(e){//touch
- e.preventDefault();
- var
- touch=e.touches[0]; 🎜>
- function touchMove(e){//Slide e.preventDefault();
- var
- touch =
- e .touches[0];
- y
- = touch.pageY - startY;//Sliding distance // inner.style.webkitTransform
- = 'translate(' 0 'px, ' y 'px )'; //You can also use css3. inner.style.top
- =aboveY y "px"; //AboveY in this sentence is The position of inner after the last slide }
- function touchEnd(e){//Finger leaves the screen
- e.preventDefault();
- aboveY=parseInt(inner.style.top);//Record the internal slider after the touch is completed The sliding position is reflected in the global variable and must be converted into an integer using parseInt();
- }//
- document.getElementById("outer").addEventListener('touchstart', touchSatrt,false);
- document.getElementById("outer").addEventListener('touchmove', touchMove,false);
- document.getElementById("outer").addEventListener('touchend', touchEnd,false);
- script>
- body>
- html>
Original text:
http://www.cnblogs.com/leinov/p/3701951.html
HTML5isamajorrevisionoftheHTMLstandardthatrevolutionizeswebdevelopmentbyintroducingnewsemanticelementsandcapabilities.1)ItenhancescodereadabilityandSEOwithelementslike,,,and.2)HTML5enablesricher,interactiveexperienceswithoutplugins,allowingdirectembe

Advanced tips for H5 include: 1. Use complex graphics to draw, 2. Use WebWorkers to improve performance, 3. Enhance user experience through WebStorage, 4. Implement responsive design, 5. Use WebRTC to achieve real-time communication, 6. Perform performance optimization and best practices. These tips help developers build more dynamic, interactive and efficient web applications.

H5 (HTML5) will improve web content and design through new elements and APIs. 1) H5 enhances semantic tagging and multimedia support. 2) It introduces Canvas and SVG, enriching web design. 3) H5 works by extending HTML functionality through new tags and APIs. 4) Basic usage includes creating graphics using it, and advanced usage involves WebStorageAPI. 5) Developers need to pay attention to browser compatibility and performance optimization.

H5 brings a number of new functions and capabilities, greatly improving the interactivity and development efficiency of web pages. 1. Semantic tags such as enhance SEO. 2. Multimedia support simplifies audio and video playback through and tags. 3. Canvas drawing provides dynamic graphics drawing tools. 4. Local storage simplifies data storage through localStorage and sessionStorage. 5. The geolocation API facilitates the development of location-based services.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

The core features of HTML5 include semantic tags, multimedia support, offline storage and local storage, and form enhancement. 1. Semantic tags such as, etc. to improve code readability and SEO effect. 2. Simplify multimedia embedding with labels. 3. Offline storage and local storage such as ApplicationCache and LocalStorage support network-free operation and data storage. 4. Form enhancement introduces new input types and verification properties to simplify processing and verification.

H5 provides a variety of new features and functions, greatly enhancing the capabilities of front-end development. 1. Multimedia support: embed media through and elements, no plug-ins are required. 2. Canvas: Use elements to dynamically render 2D graphics and animations. 3. Local storage: implement persistent data storage through localStorage and sessionStorage to improve user experience.

H5 and HTML5 are different concepts: HTML5 is a version of HTML, containing new elements and APIs; H5 is a mobile application development framework based on HTML5. HTML5 parses and renders code through the browser, while H5 applications need to run containers and interact with native code through JavaScript.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use
