gpt4 book ai didi

jquery - 获取鼠标下 - 当前 DOM 元素 obj [while event-resize ] jQuery-ui

转载 作者:行者123 更新时间:2023-12-03 22:42:25 25 4
gpt4 key购买 nike

我已经设置了一个函数来跟踪文档上的鼠标事件,即使我只需要鼠标专门用于调整大小检测目的,至少在这一点上......

var BoolMouseDown = false;
var BoolResizing = false;
document.body.onmousedown = function () {
BoolMouseDown = true;
};
document.body.onmouseup = function () {
BoolMouseDown = false;
};

在用户界面上

旁注:目标是获取鼠标下每个元素的数据,以便它可以转化为征服者幸存下来的新(div)部分

// called function on resiz event

var ValueCurSourceCellId = "";
var ValueCurDestCellId = "";
function CurCellIdSet(val) {
if (BoolMouseDown) {
ValueCurDestCellId = val;
BoolMouseDown = false;
}
else {
if (BoolResizing) {
ValueCurDestCellId = val;
}
ValueCurSourceCellId = val;
}
}


var BoolHasCollided = false;
$(gitem11)
.mouseover(function () {
//cur mouse over = attribute of html-imput-hidden( curMoRszr="")
if (BoolMouseDown) return;//so if its Mouse Down - don't collect underlying element data

$elmHidData1.attr('curMoRszr', $(this).attr('id'));
CurCellIdSet($(this).attr('id'));
})
.mousedown(function () {
BoolMouseDown = true;
$elmHidData1.attr('curMoRszr', $(this).attr('id'));
CurCellIdSet($(this).attr('id'));
})
.mouseup(function () {
BoolMouseDown = false;
CurCellIdSet($(this).attr('id'));
})
.resizable({

handles: "e, s", ghost: true,
start:
// here 11 is the accident producer, 21 is the victim.
function () {
console.log("resize started");
curg21initialpositionTop = $curg21.offset().top;
curg11initialpositionTop = $curg11.offset().top;
curg11initialHeight = $curg11.css("height").substring(0, 2);
},

resize:

function (event, ui) {

var data1id = $elmHidData1.attr('curMoRszr');
if (ui.size.height + curg11initialpositionTop > curg21initialpositionTop && ui.size.height + curg11initialpositionTop < curg21initialpositionTop + 50 + gap)
{
setRszble($curg11, $curg21);
BoolHasCollided = true;
}

$(gitem31).text("p: " + ui.size.height + "curg21initialuiposition:" + curg21initialuiposition + ", " + ui.position.top);
},
stop:
// function to conclude the accident, give the new partial div a position and size
});

在此处询问时,我找到的最接近的帖子是 This^

收集调整大小事件数据的正确方法是什么?

最佳答案

在 Javascript 中你可以这样做:

document.elementFromPoint(x, y);

其中 x 和 y 将是鼠标位置(我假设您可以自己获取该指针位置)

从那里您可以获取所需元素的数据。

关于jquery - 获取鼠标下 - 当前 DOM 元素 obj [while event-resize ] jQuery-ui,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35768544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com