-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dom,事件程序有,react-router,forEach,hover
- Loading branch information
Showing
8 changed files
with
176 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# hover 与 visibility | ||
|
||
## 1.发现:当 visibility:hidden 的时候不能够响应 hover | ||
|
||
不知道为什么 | ||
 | ||
但是在设置样式中可以看见样式,并且点击 hover 生效 | ||
 | ||
|
||
解决办法:使用 opacity:0 实现隐藏 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 获取元素位置高度宽度信息 | ||
|
||
## 1.元素大小 | ||
|
||
- 不包括 border,不受滚动条影响 | ||
|
||
element.clientWidth | ||
|
||
element.clientHeight | ||
|
||
- 包括 border,不受滚动条影响 | ||
|
||
element.offsetWidth | ||
|
||
element.offsetHeight | ||
|
||
- 出现滚动条 | ||
element.scrollWidth | ||
|
||
element.scrollHeight = scrollTop + clientHeight | ||
|
||
## 2.鼠标点击事件 | ||
|
||
- 距离浏览器视口 | ||
|
||
element.clientX | ||
|
||
element.clientY | ||
|
||
- 点击位置相对于点击的对象的位置 | ||
|
||
element.offsetX | ||
|
||
element.offsetY | ||
|
||
## 3.相对于 offsetParent | ||
|
||
- 前提条件:最近的父元素 position:relative/absolute | ||
|
||
element.offsetTop | ||
|
||
element.offsetLeft | ||
|
||
## 4.出现滚动条 | ||
|
||
- 滚动条拉动的距离 | ||
|
||
scrollLeft | ||
|
||
scrollTop | ||
|
||
## 5.获取元素到视口的距离 | ||
|
||
- getBoundingClientRect 方法返回元素的大小及其相对于视口的位置。 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 2021-01-04 事件回调函数防抖传参 | ||
|
||
防抖函数使用 lodash debounce | ||
|
||
```js | ||
const abc = '123'; | ||
element.addEventListener('mouseover', (event) => mouseoverDebounce(event, abc)); | ||
|
||
const mouseover = callback((event, abc) => {}, []); | ||
|
||
const mouseoverDebounce = _.debounce( | ||
(event, abc) => mouseover(event, abc), | ||
500 | ||
); | ||
``` | ||
|
||
//不能 remove? 匿名函数不可以移除,因为因为传入的事件处理函数不是同一个 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# react-router 传参 | ||
|
||
https://blog.csdn.net/chad97/article/details/89339465 |