OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
6 Code distributed by Google as part of the polymer project is also | |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
8 --><!-- | |
9 `core-image` is an element for displaying an image that provides useful sizing a
nd | |
10 preloading options not found on the standard `<img>` tag. | |
11 | |
12 The `sizing` option allows the image to be either cropped (`cover`) or | |
13 letterboxed (`contain`) to fill a fixed user-size placed on the element. | |
14 | |
15 The `preload` option prevents the browser from rendering the image until the | |
16 image is fully loaded. In the interim, either the element's CSS `background-col
or` | |
17 can be be used as the placeholder, or the `placeholder` property can be | |
18 set to a URL (preferably a data-URI, for instant rendering) for an | |
19 placeholder image. | |
20 | |
21 The `fade` option (only valid when `preload` is set) will cause the placeholder | |
22 image/color to be faded out once the image is rendered. | |
23 | |
24 Examples: | |
25 | |
26 Basically identical to <img src="..."> tag: | |
27 | |
28 <core-image src="http://lorempixel.com/400/400"></core-image> | |
29 | |
30 Will letterbox the image to fit: | |
31 | |
32 <core-image style="width:400px; height:400px;" sizing="contain" | |
33 src="http://lorempixel.com/600/400"></core-image> | |
34 | |
35 Will crop the image to fit: | |
36 | |
37 <core-image style="width:400px; height:400px;" sizing="cover" | |
38 src="http://lorempixel.com/600/400"></core-image> | |
39 | |
40 Will show light-gray background until the image loads: | |
41 | |
42 <core-image style="width:400px; height:400px; background-color: lightgray;" | |
43 sizing="cover" preload src="http://lorempixel.com/600/400"></core-image> | |
44 | |
45 Will show a base-64 encoded placeholder image until the image loads: | |
46 | |
47 <core-image style="width:400px; height:400px;" placeholder="data:image/gif;b
ase64,..." | |
48 sizing="cover" preload src="http://lorempixel.com/600/400"></core-image> | |
49 | |
50 Will fade the light-gray background out once the image is loaded: | |
51 | |
52 <core-image style="width:400px; height:400px; background-color: lightgray;" | |
53 sizing="cover" preload fade src="http://lorempixel.com/600/400"></core-ima
ge> | |
54 | |
55 | |
56 @group Polymer Core Elements | |
57 @element core-image | |
58 @homepage github.io | |
59 --><html><head><link rel="import" href="../polymer/polymer.html"> | |
60 | |
61 </head><body><polymer-element name="core-image" assetpath=""> | |
62 <template> | |
63 <link rel="stylesheet" href="core-image.css"> | |
64 <template if="{{!sizing}}"> | |
65 <img id="img"> | |
66 </template> | |
67 <template if="{{preload && fade}}"> | |
68 <div id="placeholder" fit=""></div> | |
69 </template> | |
70 <content></content> | |
71 </template> | |
72 | |
73 </polymer-element> | |
74 <script charset="utf-8" src="core-image-extracted.js"></script></body></html> | |
OLD | NEW |