本文目录

插件 jQuery.appear 中文API文档

🌙
手机阅读
本文目录结构

插件 jQuery.appear 中文API文档 https://github.com/morr/jquery.appear

jquery-appear-original

This is a total revamp of original jquery.appear plugin hosted on http://code.google.com/p/jquery-appear/

Demo page

This plugin can be used to prevent unnecessary processing for content that is hidden or is outside of the browser viewport.

It implements a custom appear/disappear events which are fired when an element became visible/invisible in the browser viewport.

Installation

yarn

yarn add jquery-appear-original

npm

npm i -S jquery-appear-original

Usage

  $.appear('someselector', options); // It supports optional hash with "force_process" and "interval" keys. Check source code for details.

  $('<div>test</div>').appear(); // It also supports raw DOM nodes wrapped in jQuery.

  $('someselector').on('appear', function(event, $all_appeared_elements) {
    // this element is now inside browser viewport
  });
  $('someselector').on('disappear', function(event, $all_disappeared_elements) {
    // this element is now outside browser viewport
  });

If you want to fire appear event for elements which are close to viewport but are not visible yet, you may add data attributes appear-top-offset and appear-left-offset to DOM nodes.

  <div class="postloader" data-appear-top-offset="600">...</div> # appear will be fired when an element is below browser viewport for 600 or less pixels

Appear check can be forced by calling $.force_appear(). This is suitable in cases when page is in initial state (not scrolled and not resized) and when you want manually trigger appearance check.

Also this plugin provides custom jQuery filter for manual checking element appearance.

  $('someselector').is(':appeared')

License

MIT

AXIHE / 精选资源

浏览全部教程

面试题

学习网站

前端培训
自己甄别

前端书籍

关于朱安邦

我叫 朱安邦,阿西河的站长,在杭州。

以前是一名平面设计师,后来开始接接触前端开发,主要研究前端技术中的JS方向。

业余时间我喜欢分享和交流自己的技术,欢迎大家关注我的 Bilibili

关注我: Github / 知乎

于2021年离开前端领域,目前重心放在研究区块链上面了

我叫朱安邦,阿西河的站长

目前在杭州从事区块链周边的开发工作,机械专业,以前从事平面设计工作。

2014年底脱产在老家自学6个月的前端技术,自学期间几乎从未出过家门,最终找到了满意的前端工作。更多>

于2021年离开前端领域,目前从事区块链方面工作了