OLD | NEW |
(Empty) | |
| 1 |
| 2 <!--- |
| 3 |
| 4 This README is automatically generated from the comments in these files: |
| 5 iron-image.html |
| 6 |
| 7 Edit those files, and our readme bot will duplicate them over here! |
| 8 Edit this file, and the bot will squash your changes :) |
| 9 |
| 10 --> |
| 11 |
| 12 [![Build Status](https://travis-ci.org/PolymerElements/iron-image.svg?branch=mas
ter)](https://travis-ci.org/PolymerElements/iron-image) |
| 13 |
| 14 _[Demo and API Docs](https://elements.polymer-project.org/elements/iron-image)_ |
| 15 |
| 16 |
| 17 ##<iron-image> |
| 18 |
| 19 |
| 20 `iron-image` is an element for displaying an image that provides useful sizing a
nd |
| 21 preloading options not found on the standard `<img>` tag. |
| 22 |
| 23 The `sizing` option allows the image to be either cropped (`cover`) or |
| 24 letterboxed (`contain`) to fill a fixed user-size placed on the element. |
| 25 |
| 26 The `preload` option prevents the browser from rendering the image until the |
| 27 image is fully loaded. In the interim, either the element's CSS `background-col
or` |
| 28 can be be used as the placeholder, or the `placeholder` property can be |
| 29 set to a URL (preferably a data-URI, for instant rendering) for an |
| 30 placeholder image. |
| 31 |
| 32 The `fade` option (only valid when `preload` is set) will cause the placeholder |
| 33 image/color to be faded out once the image is rendered. |
| 34 |
| 35 Examples: |
| 36 |
| 37 Basically identical to <img src="..."> tag: |
| 38 |
| 39 <iron-image src="http://lorempixel.com/400/400"></iron-image> |
| 40 |
| 41 Will letterbox the image to fit: |
| 42 |
| 43 <iron-image style="width:400px; height:400px;" sizing="contain" |
| 44 src="http://lorempixel.com/600/400"></iron-image> |
| 45 |
| 46 Will crop the image to fit: |
| 47 |
| 48 <iron-image style="width:400px; height:400px;" sizing="cover" |
| 49 src="http://lorempixel.com/600/400"></iron-image> |
| 50 |
| 51 Will show light-gray background until the image loads: |
| 52 |
| 53 <iron-image style="width:400px; height:400px; background-color: lightgray;" |
| 54 sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image> |
| 55 |
| 56 Will show a base-64 encoded placeholder image until the image loads: |
| 57 |
| 58 <iron-image style="width:400px; height:400px;" placeholder="data:image/gif;b
ase64,..." |
| 59 sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image> |
| 60 |
| 61 Will fade the light-gray background out once the image is loaded: |
| 62 |
| 63 <iron-image style="width:400px; height:400px; background-color: lightgray;" |
| 64 sizing="cover" preload fade src="http://lorempixel.com/600/400"></iron-ima
ge> |
| 65 |
| 66 Custom property | Description | Default |
| 67 ----------------|-------------|---------- |
| 68 `--iron-image-placeholder` | Mixin applied to #placeholder | `{}` |
| 69 `--iron-image-width` | Sets the width of the wrapped image | `auto` |
| 70 `--iron-image-height` | Sets the height of the wrapped image | `auto` |
| 71 |
| 72 |
OLD | NEW |