{"_id":"@autofe/lazyload","_rev":"8-fb52dba1e610a3348957aceb9a871d6d","name":"@autofe/lazyload","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"@autofe/lazyload","version":"0.1.0","keywords":["library","autohome","lazyload"],"author":{"name":"jpuncle","email":"zhangxingkai@autohome.com.cn"},"license":"MIT","_id":"@autofe/lazyload@0.1.0","maintainers":[{"name":"jpuncle","email":"jack_zhxk@163.com"}],"homepage":"https://github.com/athm-fe/lazyload#readme","bugs":{"url":"https://github.com/athm-fe/lazyload/issues"},"dist":{"shasum":"a060cd911e991fc3fc3dfca06ea3b85b76b731c7","tarball":"https://registry.npmjs.org/@autofe/lazyload/-/lazyload-0.1.0.tgz","integrity":"sha512-yXyCffnzV2GmZU7jTSW87E6e5TSCOPoMMccuR9Qr3U4sScG2VPG2okYT1e6BGnxWEAIm7UOJcboXe2mJGgPuuA==","signatures":[{"sig":"MEYCIQDtzbp0+jt5Qbha8x5Uaw75zg1quMNLwQ6iTsjnw/w/sgIhAP4en9U9jRh4Hju55rA24AfB8NlPQAR5jUVGkF8engxZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"dist/lazyload.js","files":["lib","dist"],"module":"src/index.js","gitHead":"221ec41f454de1d600bd525d018f4af3a6cf8645","scripts":{"lint":"eslint lib test","test":"echo \"Error: no test specified\" && exit 1","build":"npm run lint && rollup -c ./rollup.config.js","minify":"uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --output dist/lazyload.min.js dist/lazyload.js","release":"npm run build && npm run minify"},"_npmUser":{"name":"jpuncle","email":"jack_zhxk@163.com"},"repository":{"url":"git+https://github.com/athm-fe/lazyload.git","type":"git"},"_npmVersion":"5.6.0","description":"A Lazyload library based on jQuery","directories":{},"_nodeVersion":"8.6.0","dependencies":{"jquery":"^3.2.1"},"devDependencies":{"eslint":"^4.15.0","rollup":"^0.54.0","uglify-js":"^3.3.7","babel-core":"^6.26.0","rollup-plugin-babel":"^3.0.3","rollup-plugin-commonjs":"^8.2.6","babel-preset-autofe-app":"^1.2.0","rollup-plugin-node-resolve":"^3.0.2"},"_npmOperationalInternal":{"tmp":"tmp/lazyload-0.1.0.tgz_1517451510243_0.14260892081074417","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@autofe/lazyload","version":"0.2.0","keywords":["library","autohome","lazyload"],"author":{"name":"jpuncle","email":"zhangxingkai@autohome.com.cn"},"license":"MIT","_id":"@autofe/lazyload@0.2.0","maintainers":[{"name":"jpuncle","email":"jack_zhxk@163.com"},{"name":"mercysnake","email":"lonjas@163.com"}],"homepage":"https://github.com/athm-fe/lazyload#readme","bugs":{"url":"https://github.com/athm-fe/lazyload/issues"},"dist":{"shasum":"11027c99022fe9e7e2655d16bcdd620310423a39","tarball":"https://registry.npmjs.org/@autofe/lazyload/-/lazyload-0.2.0.tgz","fileCount":7,"integrity":"sha512-xc0B4vqYOUdl+H0W3KLR8hxB09FDWmW9p6pcv7BJgvIAjaQyQ51ELKhKi+ymuaZIFUyC7sbUgwQr4Ein8EzQdg==","signatures":[{"sig":"MEUCIQCgLgq006p0KqXsBvWFWBUc2e30KbLVtT+w4xTuX19yswIgYqIt9j2DrrkG61VUZ1SbOM4rh+HB71h/YoihZaTwPy0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29250},"main":"dist/lazyload.js","files":["lib","dist"],"module":"src/index.js","gitHead":"d68ea797b22e019f6770f94023b58e221af66dd8","scripts":{"lint":"eslint lib test","test":"echo \"Error: no test specified\" && exit 1","build":"npm run lint && rollup -c ./rollup.config.js","minify":"uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --output dist/lazyload.min.js dist/lazyload.js","release":"npm run build && npm run minify"},"_npmUser":{"name":"jpuncle","email":"jack_zhxk@163.com"},"repository":{"url":"git+https://github.com/athm-fe/lazyload.git","type":"git"},"_npmVersion":"5.6.0","description":"A Lazyload library based on jQuery","directories":{},"_nodeVersion":"8.6.0","dependencies":{"jquery":"^3.2.1"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^4.15.0","rollup":"^0.54.0","uglify-js":"^3.3.7","babel-core":"^6.26.0","rollup-plugin-babel":"^3.0.3","rollup-plugin-commonjs":"^8.2.6","babel-preset-autofe-app":"^1.2.0","rollup-plugin-node-resolve":"^3.0.2"},"_npmOperationalInternal":{"tmp":"tmp/lazyload_0.2.0_1520910734861_0.8847132386735677","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@autofe/lazyload","version":"0.3.0","keywords":["library","autohome","lazyload"],"author":{"name":"jpuncle","email":"zhangxingkai@autohome.com.cn"},"license":"MIT","_id":"@autofe/lazyload@0.3.0","maintainers":[{"name":"jpuncle","email":"jack_zhxk@163.com"},{"name":"kabulore","email":"kabulore@gmail.com"},{"name":"mercysnake","email":"lonjas@163.com"}],"homepage":"https://github.com/athm-fe/lazyload#readme","bugs":{"url":"https://github.com/athm-fe/lazyload/issues"},"dist":{"shasum":"3fcedc676aa6a2e7c0571a456b5a4418594d7eb6","tarball":"https://registry.npmjs.org/@autofe/lazyload/-/lazyload-0.3.0.tgz","fileCount":7,"integrity":"sha512-NIwINUOmYq/Eeb+QwRWV0iutLufR+uBlaaaGAbOuClMC+R1KM0CDRg9TthCgTNl713qTlePCJg205PaX/LMkNg==","signatures":[{"sig":"MEUCIQCt0tN8tJ4x6ulminmr9T2FtRT13G/kXe6r4dQ8eYlhOwIgaesUA+KXbYIPExyLVYWedBYWU3bvNVr3VP8X1/nJysQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30185,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdTkmVCRA9TVsSAnZWagAAOEsP/0VbhpUhe6EFpH9+KWZt\nb1/ItslDditnsynGGYJmyUB8ovm37ElYd8EhbXA42F2WLQ3hIbEhnm8fJloF\nVWhnetAH6dQtXEqgzh0s8PAhtWjHStEENGX6FI4pUpS6D3A1WehcncjfGnsW\nmpzDGTDypdLmIynpJc1IqCDyc6jD1XLbOnUPqYs2sjAk/7MCvim2cWdnekZ9\nRj446cl0n8A2Gqhfl1N5j42+4waDvAef5wGM4+Wi7x9utF2phKJeOuSRZcng\n3M0TNmW6nRAOP8nmC3+vfhLxDOuPKvA2tawhrx3ITCF/iFFt0HuytXL27q5i\npm5nvrW3Ku3yk/X26AVHS75iTKlQsxU68Y2rm1G0aWBw/Ze6KUpeOkN55oci\nyil9VjgWHWU0+P09nj8z8bsMQiv6raweDVGsxsqOL4f5mfBM6KOdk4sRA8YJ\nw4on7cu11IGtg97lTPvAFNzLcwJH9W8+MTbWCEiNXpt+hjTnzcVXKlNmuCTR\nW/LfFlxJV5uWpm7CV5qLFxfAGIgjMzukKIZ5F+ngOJpserhDG3b2fD8bFcsI\nzgFwmvOi0XcaEdgNizVKSwJiKcI+PYpDOGnzwaXIGrjyMD9wFnttjQDuiS+x\nIQsqRnqts0GOXJ51pOAwe5Cj2RxlCMy7DGBQ+zXM+rem8RKGhpKHmUYg3203\n+nZd\r\n=Gu+s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/lazyload.js","module":"src/index.js","gitHead":"3e964a887fe8736f48b8b99148391aa9778fcad3","scripts":{"lint":"eslint lib test","test":"echo \"Error: no test specified\" && exit 1","build":"npm run lint && rollup -c ./rollup.config.js","minify":"uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --output dist/lazyload.min.js dist/lazyload.js","release":"npm run build && npm run minify"},"_npmUser":{"name":"jpuncle","email":"jack_zhxk@163.com"},"repository":{"url":"git+https://github.com/athm-fe/lazyload.git","type":"git"},"_npmVersion":"6.9.0","description":"A Lazyload library based on jQuery","directories":{},"_nodeVersion":"10.16.0","dependencies":{"jquery":"^3.2.1"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^4.15.0","rollup":"^0.54.0","uglify-js":"^3.3.7","babel-core":"^6.26.0","rollup-plugin-babel":"^3.0.3","rollup-plugin-commonjs":"^8.2.6","babel-preset-autofe-app":"^1.2.0","rollup-plugin-node-resolve":"^3.0.2"},"_npmOperationalInternal":{"tmp":"tmp/lazyload_0.3.0_1565411733199_0.5698654693495364","host":"s3://npm-registry-packages"}}},"time":{"created":"2018-02-01T02:18:30.315Z","modified":"2026-01-14T03:50:13.252Z","0.1.0":"2018-02-01T02:18:30.315Z","0.2.0":"2018-03-13T03:12:14.916Z","0.3.0":"2019-08-10T04:35:33.325Z"},"bugs":{"url":"https://github.com/athm-fe/lazyload/issues"},"author":{"name":"jpuncle","email":"zhangxingkai@autohome.com.cn"},"license":"MIT","homepage":"https://github.com/athm-fe/lazyload#readme","keywords":["library","autohome","lazyload"],"repository":{"url":"git+https://github.com/athm-fe/lazyload.git","type":"git"},"description":"A Lazyload library based on jQuery","maintainers":[{"email":"jack_zhxk@163.com","name":"jpuncle"},{"email":"lonjas@163.com","name":"mercysnake"}],"readme":"# Lazyload\n\n支持图片懒加载，对于非图片内容，可以通过 `onAppear` 回调函数来自己处理加载逻辑.\n\n## Usage\n\n首先你需要修改你的 HTML , 配置 `data-src` 来指定实际显示的图片. 另外, 要求指定图片的尺寸.\n\n```html\n<img class=\"lazy\" data-src=\"img/example1.jpg\" width=\"640\" height=\"480\">\n<img class=\"lazy\" data-src=\"img/example2.jpg\" width=\"640\" height=\"480\">\n<img class=\"lazy\" data-src=\"img/example3.jpg\" width=\"640\" height=\"480\">\n```\n\n然后通过脚本初始化\n\n```javascript\n$('img.lazy').lazyload();\n```\n\n### 自定义图片来源\n\n```html\n<img class=\"lazy\" data-src2=\"img/example1.jpg\" width=\"640\" height=\"480\">\n<img class=\"lazy\" data-src2=\"img/example2.jpg\" width=\"640\" height=\"480\">\n<img class=\"lazy\" data-src2=\"img/example3.jpg\" width=\"640\" height=\"480\">\n```\n\n```javascript\n$('img.lazy').lazyload({\n  attr: 'data-src2'\n});\n```\n\n还可以配置函数\n\n```javascript\n$('img.lazy').lazyload({\n  attr: function () {\n    return $(this).attr('data-src2');\n  }\n});\n```\n\n### 使用 `srcset` 来支持 Retina 屏幕\n\n```html\n<img class=\"lazy\"\n  width=\"100\" height=\"75\"\n  data-src=\"demo.jpg\"\n  data-srcset=\"demo.jpg 100w, demo_2x.jpg 200w\"\n  sizes=\"100px\">\n```\n\n```javascript\n$('img.lazy').lazyload();\n```\n\n当然, 你可以可以自定义 `srcset` 来源:\n\n```javascript\n$('img.lazy').lazyload({\n  srcsetAttr: 'data-srcset2'\n});\n```\n\n或者\n\n```javascript\n$('img.lazy').lazyload({\n  srcsetAttr: function () {\n    return $(this).attr('data-srcset2');\n  }\n});\n```\n\n### 区块懒加载\n\n```html\n<style>\n  .box {\n    margin: 20px auto;\n    width: 500px;\n    height: 500px;\n    background-color: #f2f2f2;\n    transition: all 0.3s;\n  }\n  .box.active {\n    background-color: #f60;\n  }\n</style>\n<div class=\"box\"><div>\n<div class=\"box\"><div>\n<div class=\"box\"><div>\n```\n\n```javascript\n$('.box').lazyload({\n  onAppear: function () {\n    $(this).html('<span>Loaded</span>').addClass('active');\n  }\n});\n```\n\n### 直接加载图片\n\n当你不想要滚动懒加载时, 你可以直接指定一个延迟时间来加载图片, 比如 1000 毫秒后加载所有图片.\n\n```javascript\n$('.lazy').lazyload({\n  delay: 1000\n});\n```\n\n## Options\n\n参数可以通过 data attributes 或者 JavaScript 两种方式来配置.\n\nName | Type | Default | Description\n---- | ---- | ------- | -----------\ncontainer | object | `window` | 滚动容器, 默认是 `window` , 仅支持原生 Dom 对象做为参数.\nthreshold | number | 0 | 偏移值, 用户判断 DOM 是否满足条件.\ndirection | string | vertical | 方向, 用于判断 DOM 是否满足条件. 可配置 `'both'`(位于viewport内), `'vertical'`(仅考虑垂直方向), `'horizontal'`(仅考虑水平方向), `'above'`(位于viewport及上方即可).\nskipInvisible | boolean | false | 是否忽略不可见 DOM . 不建议修改此项配置\nfailureLimit | number | 0 | 懒加载内部有一个依赖图片顺序的性能优化机制, 如果你的图片顺序是错乱的, 你可以适当调大该数值.\ndelay | number | -1 | 延迟加载时间, 单位毫秒, 当 delay >= 0 时, 会在 delay 时长后立即加载所有图片.\nattr | string or function | data-src | 配置图片的 `src` 来源\nsrcsetAttr | string or function | data-srcset | 配置图片的 `srcset` 来源\nremoveAttr | boolean | true | 当图片加载完毕后，去掉 `attr` 和 `srcsetAttr` 配置的属性\nonAppear | function | null | 当 DOM 满足条件时, 触发该回调函数, 仅触发一次.\nonLoad | function | null | 仅针对图片, 当图片加载成功时触发该回调函数.\nonError | function | null | 仅针对图片, 当图片加载失败时触发该回调函数.\nplaceholder | string | 一张 base64 透明图 | 仅针对图片, 占位图, 当没有默认 `src` 属性时, 会设置这个图片.\n\n## Methods\n\n### `.lazyload(options)`\n\n初始化, 可以接受参数进行配置.\n\n```javascript\n$('img.lazy').lazyload({\n  threshold: 100\n});\n```\n\n### 手动销毁监听\n\n> 使用 $(el).lazyload(options) 方式创建的监听是 **无法** 手动（主动）去销毁监听的；（为了不影响 jQuery 的链式调用准则）\n\n1. 必须使用 `let lazyDestroyDemo = new AutoFE.Lazyload(el, options)` 来创建实例, `el` 可以是 jQuery 对象 / DOM 对象 / CSS 选择器（内部实现还是依赖 jQuery）  \n2. 当需要主动去销毁该实例的监听时，通过调用 `lazyDestroyDemo.unbind()` 来销毁  \n3. 必要时销毁实例 `lazyDestroyDemo = null`\n\n如在 Tab 形式的异步列表，在切换 Tab 时可能需要销毁之前的监听，否则会造成严重的性能问题。\n\n# End\n\nThanks to [Bootstrap](http://getbootstrap.com/) and [tuupola/jquery_lazyload](https://github.com/tuupola/jquery_lazyload)\n","readmeFilename":"README.md"}