Comments (9)
太牛了
from front-end-articles.
有个疑问:https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceObserver/observe 这个方法接受的参数是 entryTypes 而且没有 buffered 参数,而且 entryTypes 中没有 layout-shift 的 value (https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceEntry/entryType),所以这些参数的文档是哪里查的,还是说已经是过时的,文档没有记载?
from front-end-articles.
https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceObserver/observe
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe 看下英文的,中文翻译有问题。
from front-end-articles.
https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceObserver/observe
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe 看下英文的,中文翻译有问题。
感谢
from front-end-articles.
isInScreen
方法不能准确判断元素是否在可视窗口内,
const viewportWidth = window.innerWidth
const viewportHeight = window.innerHeight
// dom 对象是否在屏幕内
function isInScreen(dom) {
const rectInfo = dom.getBoundingClientRect()
if (rectInfo.left < viewportWidth && rectInfo.top < viewportHeight) {
return true
}
return false
}
按上面代码的判断方式,滚动到第二屏的时候,第一屏的元素还符合isInScreen。
from front-end-articles.
isInScreen
方法不能准确判断元素是否在可视窗口内,const viewportWidth = window.innerWidth const viewportHeight = window.innerHeight // dom 对象是否在屏幕内 function isInScreen(dom) { const rectInfo = dom.getBoundingClientRect() if (rectInfo.left < viewportWidth && rectInfo.top < viewportHeight) { return true } return false }
按上面代码的判断方式,滚动到第二屏的时候,第一屏的元素还符合isInScreen。
const viewportWidth = window.innerWidth
const viewportHeight = window.innerHeight
// dom 对象是否在屏幕内
function isInScreen(dom) {
const rectInfo = dom.getBoundingClientRect()
if (
rectInfo.left >= 0
&& rectInfo.left < viewportWidth
&& rectInfo.top >= 0
&& rectInfo.top < viewportHeight
) {
return true
}
}
用这个,文章里的不是最新版。
from front-end-articles.
学习
from front-end-articles.
getBoundingClientRect获取元素几何属性的时候,会导致回流吧?
是不是有性能问题
from front-end-articles.
getBoundingClientRect获取元素几何属性的时候,会导致回流吧? 是不是有性能问题
这个方法是获取 DOM 属性用的,并不是设置这个 DOM 元素的属性值,所以不会导致回流。
from front-end-articles.
Related Issues (20)
- 导入 PSD HOT 1
- 套件问题 HOT 2
- 如何适配呢? HOT 1
- 页面上不是经常容易出现顶部的swiper组件嘛 HOT 1
- 2021 年终总结:奔向北京,迎接 996! HOT 20
- 手把手教你写一个简易的微前端框架 HOT 5
- 点击画布中的组件没有选中的8个点 HOT 1
- 可视化拖拽组件库一些技术要点原理分析(四) HOT 16
- markdown 编辑器实现双屏同步滚动 HOT 1
- 组合功能只有在画布上操作才可以实现,在其他组件上操作会拖动组件,可以在其他逐渐锁定的情况下进行拖拽组合吗 HOT 1
- 有个疑惑点,画布上拖拽的数据是根据componentData变化的还是curComponent,没发现两者的关联之处,求指导
- qwq HOT 1
- 协同文档 HOT 1
- > > > > 你好,关于发布的部分可以详细说明下吗? HOT 2
- 【开源自荐】每日更新的前端面试题库
- Vue 加载远程组件的解决方案 HOT 2
- 一个 git 仓库下拥有多个项目的 git hooks 配置方案
- 从零开始实现一个玩具版浏览器渲染引擎
- 低代码与大语言模型的探索实践 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from front-end-articles.