javascript - 用 jQuery 模拟鼠标的圆形移动?

标签 javascript jquery mouseevent parallax

有没有办法使用 jQuery 使鼠标光标以圆形形式重复移动?

将用于测试Parallax.js GPU/CPU 上的负载。

最佳答案

无法使用 Javascript 控制用户鼠标。其背后的目的是防止点击劫持和光标劫持。考虑以下场景:

1) User clicks a link.
2) Javascript forces the mouse to move to another link prior to click.
3) User ends up clicking a link with lots of NSFW stuff and gets fired.

另外,从 Cookieclicker 的 Angular 考虑另一种情况:

1) User injects a cursor automation script into console.
2) User proceeds to play the game without making a single click themselves.

<小时/>

光标控制的替代方法

但是,您可以查找可以模拟事件的框架的 Javascript 页面自动化测试,而不是移动鼠标光标的方法;包括光标移动。 <强> This 将是可以为您控制鼠标的第三方应用程序。您还可以使用 jQuery trigger用于当 origin-x 或 y 更改时触发的自定义事件。

Parallax Engine that reacts to the orientation of a smart device. Where no gyroscope or motion detection hardware is available, the position of the cursor is used instead.

我们从它的文档中看到 Parallax 是一个对光标事件使用react的库。此外,从我看来,光标位置似乎被转换为origin-x和origin-y输入;两个值的默认值为 0.5(视口(viewport)的中心),x - 0 为左,1 为右,y - 0 为顶部,1 为底部。与其为光标创建自动化,不如自动化这些值来模拟某些运动所需的输入。

关于javascript - 用 jQuery 模拟鼠标的圆形移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27068839/

相关文章:

css - 更改 "before"行为

javascript - Stripe.setPublishableKey 不是函数错误?

javascript - 显示与所需引用相匹配的正确项目

javascript - 可点击的按钮而不是单选按钮

javascript - Rails 4 在尝试使用 AJAX 时将 JS 加载为纯文本

jquery - 使用 MVC 从脚本和/或 Razor 模型 View 中显示和隐藏元素

java - 使用 acm.graphics 时 mouseListener 的语法是什么

javascript - 如何使 JavaScript 中的鼠标悬停功能占用更少的资源?

javascript - 开 Jest |测试.每个表|如何使用 beforeAll 函数中定义的变量配置 test.each 表

c# - 尝试动态生成 JavaScript 函数调用并传递字符串