search
HomeWeb Front-endJS Tutorialjs code to record mouse trajectory and play back_javascript skills

Problems encountered:
Question
①: In the mousemove event, a lot of left and top will be recorded in the move method. I only need a few sets of data, not so much;
Question
②: During playback, the execution in the for loop was too fast, and the result was that the start and end positions were directly visible. I wanted to slow down the middle process; I created a delay function, but there was still no substantial solution. .

Slowly drag the small square to a new position, then release the mouse,

Click "Reset" first, then click "Playback" to view the path passed,
There is only one chance - -|||
Part of the code delayed in the loop:

Copy code The code is as follows:

//Delay method
sleep: function(n) {
var start = new Date().getTime();
while (true)
if (new Date().getTime() - start > n)
break;
},
//Look back at the track record
backTrack: function() {
var oSlippage = document.getElementById("slippage");
var len = this.X.length;
for (var i = 0; i oSlippage.style.left = this. 🎜>}
}


The effect of slow playback is still not achieved and needs to be solved. . .
Aha, it was solved this morning~!
No need for for loop, use the timer to use the array subscript to continuously change the left and top of the small square


Timer combined with the array subscript



Copy code
The code is as follows: //Delay methodsleep: function(n) {
//var start = new Date().getTime();
//while (true)
// if (new Date().getTime() - start > n)
// break;
var oSlippage = document.getElementById("slippage");
oSlippage.style.left = this.X[this.iNum] - this.relativeX; //iNum is the array subscript
oSlippage.style.top = this.Y[this.iNum] - this.relativeY;
MOUSETRACKRECORD.iNum ;
//If the subscript is greater than its length, stop playback
if (this.iNum > this.X .length - 1) {
clearInterval(this.timeID);
}
},
//Look back at the track record
backTrack: function() {
//var oSlippage = document.getElementById("slippage");
//var len = this.X.length;
//for (var i = 0; i // oSlippage .style.left = this.X[i] - this.relativeX;
// oSlippage.style.top = this.Y[i] - this.relativeY;
// //Delay loop method
// this.sleep(10);
//}
this.timeID = setInterval("MOUSETRACKRECORD.sleep()", 10);
}


Demo Effect:




[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
腾讯会议怎么看回放腾讯会议怎么看回放Feb 24, 2024 am 11:10 AM

腾讯会议怎么看回放?腾讯会议中是可以观看回放的,但是多数的小伙伴不知道腾讯会议如何查看回放,接下来就是小编为用户带来的腾讯会议查看回放方法图文教程,感兴趣的用户快来一起看看吧!腾讯会议怎么看回放1、首先打开腾讯会议APP,主页面左上角【头像】点击;2、然后跳转到如下图所示的界面,点击【我的录制】服务;3、接着在我的录制页面,寻找你需要观看回放的资源;4、最后即可查看自己录制的视频回放了。

edge浏览器怎么显示鼠标运动轨迹_edge浏览器显示鼠标运动轨迹操作步骤edge浏览器怎么显示鼠标运动轨迹_edge浏览器显示鼠标运动轨迹操作步骤Apr 02, 2024 pm 05:30 PM

1、首先打开edge浏览器,点击插进来的鼠标手势的图标。2、然后在弹出的窗口中点击设置按钮。3、接着点击高级设置的快捷链接。4、随后找到显示鼠标轨迹设置项。5、之后勾选该设置项前面的复选框。6、这样在使用鼠标手势的时候,就会显示出鼠标的运行轨迹了。

腾讯课堂回放怎么看腾讯课堂回放怎么看Mar 02, 2024 pm 06:31 PM

[回放]是腾讯课堂中非常好用的功能,有些用户想要知道回放应该怎么才能看到,需要我们在完成课程中点击想要回放的视频即可看到了,这篇回放查看方法介绍就能够告诉大家具体的操作方法,下面就是详细的内容介绍。腾讯课堂回放怎么看答:已完成的课程里选择视频即可。详情介绍:1、点击软件最下方的【课程表】。2、进入自己的课程。3、选择需要看回放的章节视频,进入即可。

花椒直播回放怎么看花椒直播回放怎么看Feb 23, 2024 pm 04:04 PM

花椒直播回放怎么看?花椒直播APP中是可以观看到回放的视频,但是很多用户不知道如何在花椒直播中观看回放视频,接下来就是小编为用户带来的花椒直播回放观看方法图文教程,感兴趣的用户快来一起看看吧!花椒直播使用教程花椒直播回放怎么看1、首先打开花椒直播APP,主页面选择喜爱的博主直播间点击进入;2、然后在主播直播间中点击左上角的【头像】;3、之后跳转到下图所示的界面,再次点击【头像】;4、最后选择作品即可发现回放两字点击即可观看。

高德地图ar导航可以回放吗_高德地图ar回放导航的方法高德地图ar导航可以回放吗_高德地图ar回放导航的方法Apr 01, 2024 pm 08:28 PM

1、用户使用高德地图AR导航的过程中,系统不会录制视频,所以无法查看回放。2、大家可以在开启AR步行导航功能后,使用第三方录屏工具进行录制,然后就可以查看回放了。苹果手机可以直接使用系统自带的录屏功能进行录制,安全用户下载第三方录制软件录屏就行了。4、视频录制完成后,就可以前往手机相册,或是相应的录屏软件中查看高德AR导航的视频回放内容。

虎牙直播怎么看直播回放 虎牙直播看直播回放具体操作步骤虎牙直播怎么看直播回放 虎牙直播看直播回放具体操作步骤Mar 29, 2024 am 08:11 AM

  虎牙直播是一款依旧爆火的直播平台,虎牙直播中我们可以看到各种各样的直播,每一场直播都是非常好看的,要是有自己喜欢的直播可以去重复的观看,让自己能看到更多有趣的场面。在这里面,我们要怎么样去看直播回放呢?如何查看直播回放?很多小伙伴都搞不明白具体的方法,所以,小编已经把查看直播回放的攻略准备好在本站本站中,让我们一起来看看具体的方法吧。虎牙直播看直播回放具体操作步骤  1、首先打开手机上的虎牙直播APP,打开,进入主页面后,点击右下角的【我的】选项在我打开的页面上,在我的订阅中,找到我们想要观

虎牙直播怎么看直播回放 虎牙主播直播回放哪里看虎牙直播怎么看直播回放 虎牙主播直播回放哪里看Mar 30, 2024 pm 04:11 PM

  虎牙直播APP上的功能比较多,都能够让大家在这无限制的观看到各种类型的直播,毕竟这里的直播类型也是非常的多,都能够让你们自由的选择,且大家在这里看的时间久的话,都能够有着自己喜欢的各种主播,都是想要天天看他们的直播节目的,但是有些时候,不能及时的观看到他们的直播,大家就是能够选择进行直播回看,补回自己的遗憾的,具体的查看直播回放的功能给你们整理出来了,大家可以来看看的。虎牙直播看直播回放的方法:  首先打开虎牙app,然后进入个人主页,点击【我的订阅】。  点击后进入正在直播的直播间。  然

如何实现在线答题中的答题过程录制和回放功能如何实现在线答题中的答题过程录制和回放功能Sep 24, 2023 am 11:01 AM

如何实现在线答题中的答题过程录制和回放功能随着科技的发展,在线教育和在线学习已经成为了一种主流的学习方式。在在线教育过程中,答题环节是非常重要的一环。为了更好地了解学生的学习情况以及分析学生的答题过程,我们需要实现在线答题中的答题过程录制和回放功能。实现在线答题中的答题过程录制和回放功能的关键是要能够记录学生的答题情况并将其保存下来,以便之后进行回放。下面将

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft