tampermoney或javascript实现宽页面拖动

// ==UserScript==
// @name         页面平移功能
// @namespace    http://tampermonkey.net/
// @version      2024-01-10
// @description  try to take over the world!
// @author       songaimin
// @match        https://oa.aaaa.com/admin/flow/*/flow
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zlgx.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...

    function myGetByClass(className){
        return document.getElementsByClassName(className);
    }
    function moveTop(num){
        myGetByClass("FlowEditor_container__ORjL1")[0].scrollTop = myGetByClass("FlowEditor_container__ORjL1")[0].scrollTop+num;
    }

    function moveLeft(num){
        myGetByClass("FlowEditor_container__ORjL1")[0].scrollLeft = myGetByClass("FlowEditor_container__ORjL1")[0].scrollLeft+num;
    }

    var lastX,lastY,dragTimer;
    function mouseDown(e){
        lastX=e.x;
        lastY=e.y;
        dragTimer = setTimeout(function(){myGetByClass("FlowEditor_container__ORjL1")[0].onmousemove = mouseMove;document.body.style.cursor = "move" ;},300);
    }
    function mouseUp(e){
        clearTimeout(dragTimer);
        myGetByClass("FlowEditor_container__ORjL1")[0].onmousemove = function(){return false;};
        document.body.style.cursor = "auto" ;
    }
    function mouseMove(e){
        moveTop(lastY-e.y);
        moveLeft(lastX-e.x);
        lastX=e.x;
        lastY=e.y;
    }

    setTimeout(function(){
        console.log("拖动生效")
        myGetByClass("FlowEditor_container__ORjL1")[0].onmousedown=mouseDown;
        myGetByClass("FlowEditor_container__ORjL1")[0].onmouseup=mouseUp;
    }, 1200);

})();

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值