7.1.5 • Published 2 years ago

@electrovir/resizable-image-element v7.1.5

Weekly downloads
-
License
(MIT or CC0 1.0)
Repository
github
Last release
2 years ago

resizable-image-element

Arbitrary interactive resource resizing to fit within arbitrary dimensions. This original started as an image helper, but now it supports many file types including text, video, audio, etc.

Exports a native web element, VirResizableImage (for use in element-vir) or vir-resizable-image (for use as an HTML tag name) that accepts inputs of max dimensions and imageUrl. The element handles the rest!

  • constrains images to arbitrary dimensions while maintaining aspect ratio
  • works with SVGs and normal images
  • works with SVGs that have <image> elements
  • works with SVGs that rely on <script> elements without giving them access to the main window
  • works with "images" that are actually embedded HTML documents
  • tested in Safari, Chrome, and Firefox
  • fixes missing attributes on SVG images
  • handles viewBox attributes missing on the top SVG (but existing on a nested SVG element)
  • allows for arbitrary manipulation of SVG code to account for errors in the original SVG code
  • handles race conditions between loading the image and determining its size
  • handles the many race conditions between iframe loading and communicating back and forth wit them
  • handles audio files

Example

https://electrovir.github.io/resizable-image-element

Usage

npm i @electrovir/resizable-image-element

Meant for use with element-vir:

import {html} from 'element-vir';
import {VirResizableImage} from '@electrovir/resizable-image-element';

export function createTemplate() {
    return html`
        <${VirResizableImage.assign({
            imageUrl: 'https://example.com/my-image-url',
            max: {
                height: 300,
                width: 600,
            },
            min: {
                height: 100,
                width: 200,
            },
        })}></${VirResizableImage}>
    `;
}

You can also use the tag name vir-resizable-image outside of element-vir but you may have to imperatively assign inputs to make that work.

Loading placeholder

To customize the loading placeholder, use slot="loading" on a child element:

import {html} from 'element-vir';
import {VirResizableImage} from '@electrovir/resizable-image-element';

export function createTemplate() {
    return html`
        <${VirResizableImage.assign({
            imageUrl: 'https://example.com/my-image-url',
        })}>
            <div slot="loading">My custom loading</div>
        </${VirResizableImage}>
    `;
}
7.1.3

2 years ago

7.1.2

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.1.5

2 years ago

7.1.4

2 years ago

5.5.1

2 years ago

5.5.0

2 years ago

5.3.2

2 years ago

5.3.1

2 years ago

5.3.0

2 years ago

4.14.1

2 years ago

4.14.2

2 years ago

5.1.0

2 years ago

6.1.0

2 years ago

4.9.0

2 years ago

3.1.10

2 years ago

4.9.1

2 years ago

3.1.9

2 years ago

3.1.8

2 years ago

4.4.1

2 years ago

4.2.3

2 years ago

4.4.0

2 years ago

4.2.2

2 years ago

4.4.3

2 years ago

4.6.0

2 years ago

4.4.2

2 years ago

4.2.4

2 years ago

4.0.0

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.12.0

2 years ago

4.14.0

2 years ago

4.10.0

2 years ago

5.4.0

2 years ago

5.2.1

2 years ago

5.0.3

2 years ago

5.2.0

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

6.0.1

2 years ago

6.0.0

2 years ago

6.0.3

2 years ago

4.8.1

2 years ago

6.2.0

2 years ago

6.0.2

2 years ago

4.8.0

2 years ago

7.0.0

2 years ago

7.0.1

2 years ago

3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

4.5.0

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.7.0

2 years ago

4.1.0

2 years ago

4.3.0

2 years ago

4.11.0

2 years ago

4.11.1

2 years ago

4.13.0

2 years ago

4.13.1

2 years ago

3.1.4

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago