npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

my-lazyload-elements

v2.0.1

Published

lazyload

Downloads

60

Readme

my-lazyload-elements

설치

npm i my-lazyload-elements

Attributes

  • data-my-lazy-class
    • 요소가 화면에 표시되거나 가려질 시 toggle 할 클래스명
  • data-my-lazy-style
    • 요소가 화면에 표시되거나 가려질 시 toggle 할 클래스명 스타일
  • data-my-lazy-src
    • 요소가 화면에 표시되면 적용 할 src
  • data-my-lazy-*
    • 요소가 보여지고 가려질 때 마다 *에 해당하는 속성 토글
    • ex) data-my-lazy-test="123" -> 요소 노출 시 ** image 전용 **
  • data-my-lazy-loading
    • source 이미지가 불러와질 동안 표시 할 이미지

Attributes Options

  • data-my-lazy-once
    • 최초 한 번만 이벤트를 발생 시킵니다. (화면에 한 번 표시되면 더 이상 동작하지 않습니다.)

사용

  <!-- my-lazy-group -->
  <!-- 여러 요소가 묶여 있는 경우 -->
  <figure 
    class="example__image__box"
    my-lazy-group  
  >
    <picture>
      <source
        media="(min-width: 360px)"
        data-my-lazy-srcset="/samples/[email protected]"
      >
      <source
        media="(min-width: 480px)"
        data-my-lazy-srcset="/samples/[email protected]"
      >
      <source
        media="(min-width: 800px)"
        data-my-lazy-srcset="/samples/[email protected]"
      >
      <img
        class="example__image"
        alt="1 번째 OOO 이미지"
        data-my-lazy-loading="/samples/1-blur.png"
        data-my-lazy-src="/samples/1.png"
        data-my-lazy-style="border: 1px solid green"
        data-my-lazy-class="example__image--show"
      >
    </picture>
    <figcaption>보여주기 위한 샘플 이미지 입니다.</figcaption>
  </figure>

  <!-- my-lazy -->
  <!-- 단일 요소로 있는 경우 -->
  <figure class="example__image__box">
    <img
      class="example__image"
      alt="1 번째 OOO 이미지"
      data-my-lazy-loading="/samples/1-blur.png"
      data-my-lazy-src="/samples/1.png"
      data-my-lazy-style="border: 1px solid green"
      data-my-lazy-class="example__image--show"
      my-lazy
    >
    <figcaption>보여주기 위한 샘플 이미지 입니다.</figcaption>
  </figure>
const container: Element = document.body;
const myLazyLoadElements = new MyLazyLoadElements(container, {}, {
  error: (error, result) => {
    if (result?.element instanceof HTMLImageElement) result.element.src = './assets/logo.png';
  },
  ...
});

Examples