4
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
Code distributed by Google as part of the polymer project is also
9
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
14
<title>iron-image demo</title>
16
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
17
<meta name="mobile-web-app-capable" content="yes">
18
<meta name="apple-mobile-web-app-capable" content="yes">
20
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
22
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
23
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
24
<link rel="import" href="../../polymer/polymer.html">
25
<link rel="import" href="../iron-image.html">
27
<style is="custom-style" include="demo-pages-shared-styles">
40
document.getElementById(id).src = "./polymer.svg?" + Math.random();
47
<div class="vertical-section-container centered">
49
<h3>A plain <code>iron-image</code>.</h3>
50
<demo-snippet class="centered-demo">
52
<iron-image alt="The Polymer logo." src="./polymer.svg"></iron-image>
57
<code>sizing="cover"</code> expands the image to cover all of its
60
<demo-snippet class="centered-demo">
62
<style is="custom-style">
63
#example-sizing-cover {
70
<iron-image sizing="cover" id="example-sizing-cover" alt="The Polymer logo." src="./polymer.svg"></iron-image>
75
<code>sizing="contain"</code> expands the image to fit within its
78
<demo-snippet class="centered-demo">
80
<style is="custom-style">
81
#example-sizing-contain {
88
<iron-image sizing="contain" id="example-sizing-contain" alt="The Polymer logo." src="./polymer.svg"></iron-image>
93
Use the <code>--iron-image-width</code> property to set the width of
94
the image wrapped by the <code>iron-image</code>.
96
<demo-snippet class="centered-demo">
98
<style is="custom-style">
99
#example-full-width-container {
101
border: 2px solid #444;
105
#example-full-width-container iron-image {
109
#example-full-width {
111
--iron-image-width: 100%;
114
#example-half-width {
116
--iron-image-width: 100%;
121
<div id="example-full-width-container">
122
<iron-image id="example-full-width" alt="The Polymer logo." src="./polymer.svg"></iron-image>
123
<iron-image id="example-half-width" alt="The Polymer logo." src="./polymer.svg"></iron-image>
129
Use the <code>--iron-image-height</code> property to set the height of
130
the image wrapped by the <code>iron-image</code>.
132
<demo-snippet class="centered-demo">
134
<style is="custom-style">
135
#example-full-height-container {
137
border: 2px solid #444;
141
#example-full-height-container iron-image{
145
#example-full-height {
147
--iron-image-height: 100%;
150
#example-half-height {
152
--iron-image-height: 100%;
157
<div id="example-full-height-container">
158
<iron-image id="example-full-height" alt="The Polymer logo." src="./polymer.svg"></iron-image>
159
<iron-image id="example-half-height" alt="The Polymer logo." src="./polymer.svg"></iron-image>
165
No placeholder is shown by default.
167
<demo-snippet class="centered-demo">
169
<style is="custom-style">
170
.example.without-preload iron-image {
177
<div class="example without-preload">
178
<button onclick="load('example-without-preload-1')">
182
<iron-image sizing="contain" alt="The Polymer logo." id="example-without-preload-1"></iron-image>
188
The <code>preload</code> attribute shows a placeholder element in front
189
of the image before it has loaded. Use the
190
<code>--iron-image-placeholder</code> CSS mixin to style it.
192
<demo-snippet class="centered-demo">
194
<style is="custom-style">
195
.example.preload iron-image {
199
--iron-image-placeholder: {
205
<div class="example preload">
206
<button onclick="load('example-preload-1')">
210
<iron-image preload id="example-preload-1" alt="The Polymer logo." class="sized" sizing="contain"></iron-image>
212
Without the <code>fade</code> attribute, the placeholder element is
213
hidden with no transition when the image loads.
215
<div class="example preload">
216
<button onclick="load('example-preload-2')">
220
<iron-image preload fade id="example-preload-2" alt="The Polymer logo." class="sized" sizing="contain"></iron-image>
222
With the <code>fade</code> attribute, the placeholder element is
223
fades away when the image loads.
229
Use the <code>placeholder</code> attribute to specify a background image
230
for the placeholder element.
232
<demo-snippet class="centered-demo">
234
<style is="custom-style">
235
.example.preload-image iron-image {
242
<div class="example preload-image">
243
<button onclick="load('example-preload-image-1')">
247
<iron-image preload placeholder="./loading.png" id="example-preload-image-1" alt="The Polymer logo." class="sized" sizing="contain"></iron-image>
249
(without <code>fade</code> attribute)
251
<div class="example preload-image">
252
<button onclick="load('example-preload-image-2')">
256
<iron-image preload placeholder="./loading.png" fade id="example-preload-image-2" alt="The Polymer logo." class="sized" sizing="contain"></iron-image>
258
(with <code>fade</code> attribute)