Skip to content

Latest commit

 

History

History
79 lines (54 loc) · 2.43 KB

in-sight-detector.md

File metadata and controls

79 lines (54 loc) · 2.43 KB

Classes

InSightDetector

Functions

isEl(el)boolean

判断变量是否是 DOM 元素

InSightDetector

Kind: global class

new InSightDetector([options])

构造函数

Param Type Description
[options] Object 配置项,可选
[options.interval] number 检测函数执行间隔会大于等于此值
options.offset number | string 偏移量。 例如 offset 为 100 时,元素出现在窗口中的高度大于等于 100 才会触发对应回调函数。 也可以为百分比,会根据元素高度计算

inSightDetector.addListener(els, callback)

增加待检测的元素和对应的回调函数,每次新增元素时,会立即检测一次

Kind: instance method of InSightDetector

Param Type Description
els Element | Array 新增的元素,单个元素或数组
callback function 该元素处理视口区域时的回调

inSightDetector.removeListener(els)

删除指定元素及其回调函数

Kind: instance method of InSightDetector

Param Type Description
els Element | Array 待删除的元素,单个元素或数组

inSightDetector.removeAllListeners()

删除所有的元素及其回调函数

Kind: instance method of InSightDetector

isEl(el) ⇒ boolean

判断变量是否是 DOM 元素

Kind: global function
Returns: boolean - 是否是 DOM 元素

Param Type Description
el Mixed 任意变量