Java Code Implementation Micro-letter page scrolling anti-threadbare (core code) _java

Source: Internet
Author: User

Found on the Internet can prevent the page scroll to the top or bottom of the time, the leakage of the small letter ugly Gray bottom, the following little part of the core code to share for everyone's reference!

My core code:

Prevent:function () {var startx = 0, starty = 0;//touchstart event function Touchsatrtfunc (evt) {try {//evt.preventdefaul T (); To prevent the browser zoom, scroll bar scrolling, etc. var touch = evt.touches[0]; Gets the first contact var x = number (Touch.pagex); Page contact x coordinate var y = number (touch.pagey);
Page Contact y-coordinate//record contact initial position startx = x;

Starty = y;
catch (E) {alert (' Touchsatrtfunc: ' + e.message);}}
Document.addeventlistener (' Touchstart ', Touchsatrtfunc, false);
var _ss = document.getElementById ("contain"); _ss.ontouchmove = function (ev) {var _point = ev.touches[0], _top = _ss.scrolltop;//When to bottom var _bottomfaval = _ss.scro
Llheight-_ss.offsetheight; Reach Top if (_top = = 0) {//block slide down if (_point.clienty > Starty) {ev.preventdefault ();} else {//block bubbling//normal execution Ev.sto
Ppropagation ();  } else if (_top = = _bottomfaval) {//Reach bottom//block up sliding if (_point.clienty < Starty) {Ev.preventdefault ();} else {//
Block bubbling//Normal execution ev.stoppropagation (); } else if (_top > 0 && _top < _bottomfaval) {ev.stoppropagation ();}else {ev.preventdefault ();}}; }

The above code is small series to introduce the micro-letter page scrolling threadbare core code, the code is relatively simple, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.