当前位置:网站首页>Mobile dual finger scaling event (native), e.originalevent.touches
Mobile dual finger scaling event (native), e.originalevent.touches
2022-07-26 13:41:00 【Tangce】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Double finger zoom event </title>
</head>
<body>
<div class="full-bgimg">
</div>
<script> var pageX, pageY, initX, initY, isTouch = false; var start = []; $(".full-bgimg").on("touchstart",function(e){
// alert("touchstart") // Where the finger is when the finger is pressed X,Y coordinate pageX = e.originalEvent.touches[0].pageX; pageY = e.originalEvent.touches[0].pageY; // Initial position X,Y coordinate initX = e.target.offsetLeft; initY = e.target.offsetTop; // Record initial A set of data Use as zoom if (e.originalEvent.touches.length >= 2) { // Determine whether there are two points on the screen start = e.originalEvent.touches; // Get the first set of two points }; // Indicates that the finger is pressed // isTouch = true; }); $(".full-bgimg").on("touchmove",function(e){
e.preventDefault(); // A piece of finger perform The target element moves operation if (e.originalEvent.touches.length == 1 && isTouch) {}; // 2 root Finger execution Zoom in on the target element if (e.originalEvent.touches.length >= 2 && isTouch) { // alert("2") // Get the second set of two points var now = e.originalEvent.touches; Math.abs(e.originalEvent.touches[0].pageX-e.originalEvent.touches[1].pageX) // The current distance becomes smaller , getDistance Is a method of Pythagorean Theorem if(getDistance(now[0], now[1]) < getDistance(start[0], start[1])){ }; }; }) $(".full-bgimg").on("touchend",function(e){
// take isTouch It is amended as follows false Express Fingers have left the screen // if (isTouch) {isTouch = false;} }); // The zoom Pythagorean theorem method - Find the distance between two points function getDistance(p1, p2) {
var x = p2.pageX - p1.pageX, y = p2.pageY - p1.pageY; return Math.sqrt((x * x) + (y * y)); }; </script>
</body>
</html>边栏推荐
- Convert the array in JSON file to struct
- Activity.onStop() 延迟10秒?精彩绝伦的排查历程
- AI theory knowledge map 1 Foundation
- Win11+vs2019 configuration yolox
- 2022年,我们只用一个月就“送走”了这么多互联网产品
- Some practical operations of vector
- Hcip day 11 comparison (BGP configuration and release)
- HCIP第十一天比较(BGP的配置、发布)
- Leetcode 2119. number reversed twice
- B+ tree selection index (2) -- MySQL from entry to proficiency (23)
猜你喜欢

Detailed relation extraction model casrel

力扣------字符串中的单词数

【Oauth2】七、微信OAuth2授权登录

Can I take your subdomain? Exploring Same-Site Attacks in the Modern Web

官宣!艾德韦宣集团与百度希壤达成深度共创合作

Oom caused by improper use of multithreading

Concept and handling of exceptions

Photoshop(CC2020)未完

8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇

【黑马早报】字节旗下多款APP下架;三只松鼠脱氧剂泄露致孕妇误食;CBA公司向B站索赔4.06亿;马斯克否认与谷歌创始人妻子有婚外情...
随机推荐
[beauty of open source] nanomsg (2): req/rep mode
Familiarize you with the "phone book" of cloud network: DNS
Click El dropdown item/@click.native
Control the probability of random winning [C | random]
HCIP第十一天比较(BGP的配置、发布)
周伟:寻找非共识性投资机会,陪伴延迟满足的创始团队
(Reprint) creation methods of various points in ArcGIS Engine
Flutter multi-channel packaging operation
白帽子揭秘:互联网千亿黑产吓退马斯克
LCL three-phase PWM rectifier (inverter)
How to write the introduction of GIS method journals and papers?
Using the geoprocessor tool
[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp
Uncover the secret of white hat: 100 billion black products on the Internet scare musk away
LeetCode 217. 存在重复元素
Leetcode 217. there are duplicate elements
【着色器实现Overlay重新覆盖变装效果_Shader效果第九篇】
Codeforces Round #810 (Div. 2)【比赛记录】
12 brand management of commodity system in gulimall background management
如何构建以客户为中心的产品蓝图:来自首席技术官的建议