0.2.3 • Published 2 years ago

@djx/image v0.2.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@djx/image

Display images with loading behaviors and aspect ratio

Installation

npm install --save @djx/image

Usage

Make sure you import the component somewehere in your application first:

import '@djx/image';

You can then use it like normal web components in your markup:

<djx-observable-root name="@djx/image">
  <!-- Default mode (Should be fine for google) -->
  <djx-image src="https://path-to-image.jpg/"></djx-image>

  <!-- SEO optimized mode -->
  <djx-image ratio="1x1">
    <noscript>
      <img src="https://path-to-image.jpg/" />
    </noscript>
  </djx-image>
</djx-observable-root>

Make sure to define djx-observable-root if you're using lazy-v (the default)

The loading modes

The component supports 3 types of loading modes: none, lazy-v (v = visible) and lazy-i (i = instant). The default is lazy-v.

Managing the lazy-v mode

If you want to go with the most efficient, which is lazy-v, you have to define a djx-observable-root:

<!-- @djx/image is the default name -->
<djx-observable-root name="@djx/image">
  <djx-image src="https://path-to-image.jpg/"></djx-image>
</djx-observable-root>

<!-- You can use a different observable root if you want -->
<djx-observable-root name="custom-name">
  <djx-image
    observable-root="custom-name"
    src="https://path-to-image.jpg/"
  ></djx-image>
</djx-observable-root>

You can read more about the @djx/observable here

Properties

NameDescriptionDefault
srcOptional source of the imagenull
ratioThe ratio to use with the format 4x316x9
dragWheter the image should be draggablefalse
loadingThe loading mode to use (none, lazy-i, lazy-v)lazy-v
fitWheter to stretch to width or heightwidth
altAlternative text' '
observable-rootThe name of the observable root for lazy-v@djx/image

Events

NameDescription
loading-errorFired when something went wrong with the loading
loading-startFired when the loading has started
loading-endFired when the loading has ended
visibility-changedFired when the visibility of the image has changed
0.2.3

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

2 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago