🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

lazyfn

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazyfn

lazy load ajax function

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

lazyfn

当元素出现在视口时再调用相应的方法

安装

npm i lazyfn -S

使用

import lazyfn from 'lazyfn';

lazyfn(domElement,fn,toBottom,threshold,callonce);

参数:

domElement: 被监听的元素

fn: 调用的方法

toBottom: 当元素到达底部多少像素的时候触发方法,默认值为0

threshold: 何时触发回调函数,默认值为[0]

callonce: 是否只调用一次方法,默认值为true

完整例子

import lazyfn from 'lazyfn';

lazyfn(document.querySelector('#test'),()=>{
    console.log()
},0,true);

Keywords

lazy function

FAQs

Package last updated on 02 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts