您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
A simple dragging helper library
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/428694/945686/CKDragHelper.js
A simple dragging helper.
To handle a dragging action, you must have a callback function to handle each move event. This funciton will be called each MouseMoveEvent and will recieve two objects uses like below:
window.dragger.regHandler(/* func here */ (delta, lastdelta)=>{ })
delta
: Will return an object contains x
and y
which are the difference with the drag start point.lastdelta
: Will return an object contains x
and y
which are the difference with the last delta value.Noticed that callback function will be erased when dragging action is over (mouse up event) and need to re-register for next call.
Now dragger
knows how to process dragging actions, you only need to tell it when to start. It usually be a MouseDownEvent or something like that, you need to pass a paramater to the startup method which contains screenX
and screenY
attributes, it could be a MouseEvent or an object you created manually. Here is a simple sample showing the usages that when clicked a dom then start dragging:
let dom = document.querySelector("#something")
dom.onclick = e=>{
e.preventDefault()
window.dragger.startDrag(e)
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址