Skip to content

monajs/position

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

position

✨✨ 返回元素节点的位置信息,判断是否在视口范围内

npm npm

使用场景

  • 曝光埋点的时候判断是否可以曝光
  • 获取元素的位置信息,返回的信息更全 ...

安装

$ npm i --save @monajs/position

代码演示

import position from '@monajs/position'

const ele = document.querySelector('#appWrapper')
// console.log(position._position(ele))

console.log(position(ele))

返回的节点信息

{
    bottom: -133,
    bottomToTop: 800,
    el: HTMLElement,
    height: 100,
    isCompletelyInViewport: false,
    isInViewport: false,
    left: 100,
    leftToRight: -275,
    right: 175,
    rightToLeft: 200,
    screenHeight: 667,
    screenWidth: 375,
    top: 700,
    topToBottom: 33,
    width: 100,
}

联系我

微信:yx12032331

About

Analysis of node position information.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published