mouse,mouseup,mouseenter,mouseover,click坑呀,浏览器表现居然不一致;

firefox呀

直接上代码吧,自定义个el-table的select,chrome表现正常;

firefox就诡异了,mousedown->mouseup,中间不触发mouseover,mouseenter,并且鼠标移出到其它td上up后,居然只能还是在起始td上;并且必然出发click事件;

真是醉了,这个设计也太扯了!

另外扯个firefox开发者工具的鸡肋堆栈跟踪,只显示几个,根本对分析无意义,为什么不显示完整的呢?chrome的堆栈跟踪就很到位,另外html的事件跟踪也完整的。

事实证明呀,还是要走webkit的,firefox再见吧。

 1 const tableSelect: DirectiveOptions = {
2
3
4 componentUpdated: (el, binding, vnode) => {
5 let option = binding.value;
6 vnode.context?.$nextTick(() => {
7
8 var rowSelector = `.el-table__body-wrapper table.el-table__body tr.el-table__row`;
9 let clearSelected = function (option) {
10 el.querySelectorAll(`${rowSelector} td`).forEach(function (td) {
11 td.style.backgroundColor = '';
12 option.td_selected = [];
13 });
14 };
15 option.td_selected = [];
16 let td_mousedown;
17 let td_list = el.querySelectorAll(`${rowSelector} td`);
18
19 td_list.forEach(function (td) {
20 if (!td.querySelector('input')) {
21 td.onmousedown = (function (ev) {
22 document.body.onselectstart = () => true;
23 clearSelected(option);
24 });
25 td.onmouseup = (function (ev) {
26 td_mousedown = undefined;
27 });
28 return;
29 }
30 td.onmousedown = function(ev){
31
32 if (ev.button != 0) return;
33 td_mousedown = this;
34 document.body.onselectstart = () => false;
35 clearSelected(option);
36 };
37 td.onmouseover = (function (ev) {
38 console.log('onmouseover',this);
39 if (td_mousedown == undefined) return;
40 clearSelected(option);
41 //选区
42 let range = {
43 p1: {row: td_mousedown.parentNode.rowIndex, col: td_mousedown.cellIndex},
44 p2: {row: this.parentNode.rowIndex, col: this.cellIndex},
45 };
46 if (range.p1.row > range.p2.row || range.p1.col > range.p2.col) {
47 range = {p1: range.p2, p2: range.p1};
48 }
49 option.td_selected = [];
50 let rows = el.querySelectorAll(`${rowSelector}`);
51
52 for (let i = range.p1.row; i <= range.p2.row; i++) {
53 let row = rows[i];
54 let cols = row.querySelectorAll('td');
55 for (let j = range.p1.col; j <= range.p2.col; j++) {
56 let td = cols[j];
57 td.style.backgroundColor = '#3390ff';
58 option.td_selected.push({td: td, tr: row, row: i, col: j});
59 }
60 }
61 })
62 td.onmouseup = (function (ev) {
63 //console.log(this,td_mousedown)
64 if (ev.button != 0) return;
65 if (td_mousedown && td_mousedown != this) {
66 if (option.fn) {
67 option.fn(option);
68 }
69 }
70 td_mousedown = undefined;
71 });
72 });
73
74
75 });
76
77
78 }
79 }
80 ;
81 export default tableSelect;

mousedown mouseenter mouseup firefox,还是通一用webkit吧,细节的坑刚刚填,毕竟现在是webkit一家大拿!的更多相关文章

  1. click事件和mousedown、mouseup事件

    点击select标签元素的时候,会弹出下拉.然而当option中没有元素时,就不希望弹出下拉(比如在某些浏览器中,点击select会默认出一个罩层效果,而此时没有数据选择的话,弹出比较不友好). 首先 ...

  2. JavaScript区分click事件和mousedown(mouseup、mousemove)方法

    在前端开发工作中,会遇到这样问题:针对同一个dom元素,即希望为它绑定click事件,又想该元素可以允许拖拽的效果.而使用拖拽的效果,我们一般就会用到mousedown,mousemove和mouse ...

  3. JQuery使用mousedown和mouseup简单判断鼠标按下与释放位置是否相同

    在JQuery中,我们可以利用mousedown.mouseup来跟踪页面的鼠标按下与释放事件. 如何获取鼠标的位置信息呢?事件event的pageX和pageY属性可以让我们获得鼠标在页面中的具体位 ...

  4. mousedown、mouseup、click事件之间的关系及执行顺序

      三个事件的触发时机 mousedown 当鼠标指针移动到元素上方,并按下鼠标按键(左.右键均可)时,会发生 mousedown 事件.与 click 事件不同,mousedown 事件仅需要按键被 ...

  5. javascript简单拖拽(鼠标事件 mousedown mousemove mouseup)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  6. jquery事件 【mousedown与mouseup ----keydown与keypress与keyup】focus--blur--orrer--pageX-pageY

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> ...

  7. 【终极答案】搭建selenium3.11 +Firefox+python3.6自动化UI测试环境踩的坑

    1 运行之后,出现如下报错 Selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs ...

  8. 使用WatiN进行UI自动化测试

    Watin是一个UI自动化测试工具,支持ie/firefox,官方网站:http://watin.org/. 主要有以下特点: 支持主要的html元素,见:http://watin.org/docum ...

  9. 内存分配器 (Memory Allocator)

    对于大多数开发人员而言,系统的内存分配就是一个黑盒子,就是几个API的调用.有你就给我,没有我就想别的办法. 来UC前,我就是这样觉得的.实际深入进去时,才发现这个领域里也是百家争鸣.非常热闹.有操作 ...

  10. 最终解决 mouseenter, mouseleave , mouseout mousehover mousemove等事件的区别?

    在jquery中, html页面的div的显示和隐藏, 修改等的功能, 最终都要由 事件 触发来引用, 不管是键盘事件, 还是鼠标事件... mouseenter和mouseleave是成对对应的, ...

随机推荐

  1. Spring Boot项目设置跨域

    一.跨域设置 新建一个配置类 import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterC ...

  2. 解锁DeepSeek深度应用,天翼云GPU云主机强势破局!

    在人工智能重塑世界的当下,一场影响深远的科技变革正在悄然上演,DeepSeek系列模型在诸多领域掀起热潮.企业级AI模型的训练与部署,不仅是技术的角力场,更是决定企业兴衰的生死线.每一次算法的迭代革新 ...

  3. 寻找旋转排序数组中的最小值 II

    地址:https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/ <?php /** 154. 寻找旋转排 ...

  4. 【ABAQUS文档笔记】ABAQUS刚体单元和可变形单元的review

    学习笔记,帮助文档学习笔记 目录 A. finite element DOF of Elem Order of Elem Formulation of Elem Integration A.1 con ...

  5. Oracle 23ai TPC-H 执行情况

    TPC-H是一个广泛使用的基准测试,用于评估数据库系统在决策支持系统(DSS)场景下的性能. 在昨天的文章中,我们完成了<Oracle 23ai TPC-H 测试环境部署>,本文将继续记录 ...

  6. git 命令手册【不定时更新】

    本地分支 --> 远程服务器 git add xxx git commit -m "xxx" git push origin xxx 远程服务器 --> 本地分支 gi ...

  7. 自行为一加6编译Postmarket os内核

    序 在为自己的一加6刷上PostmarketOS后突然某一天想使用它的照相机功能.原因是想到使用pmos拍照后笔者可以直接使用scp指令来传输手机相片到自己运行着GNU/Linux的电脑上,就感到相对 ...

  8. DBeaver连接mysql时Public Key Retrieval is not allowed错误

    前言 DBeaver 连接 mysql 时,报错:Public Key Retrieval is not allowed 解决 在新建连接的时候,驱动属性里设置 allowPublicKeyRetri ...

  9. 云服务器下如何部署Django项目详细操作步骤

    前期本人完成了"编写你的第一个 Django 应用程序",有了一个简单的项目代码,在本地window系统自测没问题了,接下来就想办法部署到服务器上,可以通过公网访问我们的Djang ...

  10. Spring定时任务的秘密

    Spring定时任务的秘密 在 Spring 框架中,定时任务主要通过 @Scheduled 注解或 TaskScheduler 接口实现. 1.基本使用 在 Spring Boot 项目中,通过 @ ...