3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
14 <title>core-image
</title>
16 <script src=
"../webcomponentsjs/webcomponents.js"></script>
18 <link rel=
"import" href=
"core-image.html">
26 background-color: lightgray;
29 display: inline-block;
37 <template is=
"auto-binding">
38 <h3>Sizing: none (naturally sized)
</h3>
39 <core-image src=
"http://lorempixel.com/400/200/sports/1"></core-image>
41 <h3>Sizing: cover
</h3>
42 <core-image class=
"sized" sizing=
"cover" src=
"http://lorempixel.com/400/200/sports/2"></core-image>
43 <core-image class=
"sized" sizing=
"cover" src=
"http://lorempixel.com/200/400/sports/3"></core-image>
45 <h3>Sizing: contain
</h3>
46 <core-image class=
"sized gray" sizing=
"contain" src=
"http://lorempixel.com/400/200/sports/2"></core-image>
47 <core-image class=
"sized gray" sizing=
"contain" src=
"http://lorempixel.com/200/400/sports/3"></core-image>
49 <h3>Preload: none
</h3>
52 <button on-tap=
"{{preload}}" target=
"preload1a">Load image
</button><br><br>
53 <core-image id=
"preload1a" class=
"sized gray" ></core-image>
57 <button on-tap=
"{{preload}}" target=
"preload1b">Load image
</button><br><br>
58 <core-image id=
"preload1b" class=
"sized gray" sizing=
"cover" ></core-image>
62 <button on-tap=
"{{preload}}" target=
"preload1c">Load image
</button><br><br>
63 <core-image id=
"preload1c" class=
"sized gray" sizing=
"contain" ></core-image>
66 <h3>Preload: color as placeholder
</h3>
69 <button on-tap=
"{{preload}}" target=
"preload2a">Load image
</button>
70 <span hidden?=
"{{!$.preload2a.loading}}">Loading...
</span>
72 <core-image id=
"preload2a" class=
"sized gray" preload
></core-image>
76 <button on-tap=
"{{preload}}" target=
"preload2b">Load image
</button>
77 <span hidden?=
"{{!$.preload2b.loading}}">Loading...
</span>
79 <core-image id=
"preload2b" class=
"sized gray" sizing=
"cover" preload
></core-image>
83 <button on-tap=
"{{preload}}" target=
"preload2c">Load image
</button>
84 <span hidden?=
"{{!$.preload2c.loading}}">Loading...
</span>
86 <core-image id=
"preload2c" class=
"sized gray" sizing=
"contain" preload
></core-image>
89 <h3>Preload: image as placeholder
</h3>
92 <button on-tap=
"{{preload}}" target=
"preload3a">Load image
</button>
93 <span hidden?=
"{{!$.preload3a.loading}}">Loading...
</span>
95 <core-image id=
"preload3a" class=
"sized gray" preload
placeholder=
"data:image/gif;base64,R0lGODdhyADIAOMAAO7u/5aWlqGho9jY5OPj8cLCyqyssLe3vc3N1wAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAyADIAAAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS06kB1tYqA9cUBQEFrgLWAgIqBOEBFNuu1gMs2ugT3d/rAe0r77bsFwMGAQLzEggc8AcQAIJwA+EBuKbQmgF+3iocDHBAXiZ9Fd6dAxhuo4R3/gwnGDgnkqE1BBM0XrN3CSOFgQYM+ouHEsFMAP1i2lQIAN8EhwS6kZPQ74BMnpZcTgiHkoA1AhKxAWDaU+pHqwvrVVVI1ScmpRIwYjxwTqo+r1vTafV6FmtSrRXEak0ooB+8tjzR4v251m0llwSgUnUaAOrJtFMDoESrty9XxYi/wk0sMEBMoRKo7iRK8SiFxu285vQMoIDR0qdNN+rmbxxJlRFLi7u22OG1mDjP4bYb2uFVf+r0CZ+cyOS1oRD/cUM4cN5EA3bDhszqWOHEhBLIZh+qHdnmaFABwIwm9BxLZxAtn6fGvr379/Djy59Pv779+/jz69/Pv7///wAGQyjggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDRKEQEAOw=="></core-image>
99 <button on-tap=
"{{preload}}" target=
"preload3b">Load image
</button>
100 <span hidden?=
"{{!$.preload3b.loading}}">Loading...
</span>
102 <core-image id=
"preload3b" class=
"sized gray" sizing=
"cover" preload
placeholder=
"data:image/gif;base64,R0lGODdhyADIAOMAAO7u/5aWlqGho9jY5OPj8cLCyqyssLe3vc3N1wAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAyADIAAAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS06kB1tYqA9cUBQEFrgLWAgIqBOEBFNuu1gMs2ugT3d/rAe0r77bsFwMGAQLzEggc8AcQAIJwA+EBuKbQmgF+3iocDHBAXiZ9Fd6dAxhuo4R3/gwnGDgnkqE1BBM0XrN3CSOFgQYM+ouHEsFMAP1i2lQIAN8EhwS6kZPQ74BMnpZcTgiHkoA1AhKxAWDaU+pHqwvrVVVI1ScmpRIwYjxwTqo+r1vTafV6FmtSrRXEak0ooB+8tjzR4v251m0llwSgUnUaAOrJtFMDoESrty9XxYi/wk0sMEBMoRKo7iRK8SiFxu285vQMoIDR0qdNN+rmbxxJlRFLi7u22OG1mDjP4bYb2uFVf+r0CZ+cyOS1oRD/cUM4cN5EA3bDhszqWOHEhBLIZh+qHdnmaFABwIwm9BxLZxAtn6fGvr379/Djy59Pv779+/jz69/Pv7///wAGQyjggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDRKEQEAOw=="></core-image>
106 <button on-tap=
"{{preload}}" target=
"preload3c">Load image
</button>
107 <span hidden?=
"{{!$.preload3c.loading}}">Loading...
</span>
109 <core-image id=
"preload3c" class=
"sized gray" sizing=
"contain" preload
placeholder=
"data:image/gif;base64,R0lGODdhyADIAOMAAO7u/5aWlqGho9jY5OPj8cLCyqyssLe3vc3N1wAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAyADIAAAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS06kB1tYqA9cUBQEFrgLWAgIqBOEBFNuu1gMs2ugT3d/rAe0r77bsFwMGAQLzEggc8AcQAIJwA+EBuKbQmgF+3iocDHBAXiZ9Fd6dAxhuo4R3/gwnGDgnkqE1BBM0XrN3CSOFgQYM+ouHEsFMAP1i2lQIAN8EhwS6kZPQ74BMnpZcTgiHkoA1AhKxAWDaU+pHqwvrVVVI1ScmpRIwYjxwTqo+r1vTafV6FmtSrRXEak0ooB+8tjzR4v251m0llwSgUnUaAOrJtFMDoESrty9XxYi/wk0sMEBMoRKo7iRK8SiFxu285vQMoIDR0qdNN+rmbxxJlRFLi7u22OG1mDjP4bYb2uFVf+r0CZ+cyOS1oRD/cUM4cN5EA3bDhszqWOHEhBLIZh+qHdnmaFABwIwm9BxLZxAtn6fGvr379/Djy59Pv779+/jz69/Pv7///wAGQyjggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDRKEQEAOw=="></core-image>
112 <h3>Preload: color as placeholder, with Fade-in
</h3>
115 <button on-tap=
"{{preload}}" target=
"preload2afade">Load image
</button>
116 <span hidden?=
"{{!$.preload2afade.loading}}">Loading...
</span>
118 <core-image id=
"preload2afade" class=
"sized gray" preload fade
></core-image>
122 <button on-tap=
"{{preload}}" target=
"preload2bfade">Load image
</button>
123 <span hidden?=
"{{!$.preload2bfade.loading}}">Loading...
</span>
125 <core-image id=
"preload2bfade" class=
"sized gray" sizing=
"cover" preload fade
></core-image>
129 <button on-tap=
"{{preload}}" target=
"preload2cfade">Load image
</button>
130 <span hidden?=
"{{!$.preload2cfade.loading}}">Loading...
</span>
132 <core-image id=
"preload2cfade" class=
"sized gray" sizing=
"contain" preload fade
></core-image>
135 <h3>Preload: image as placeholder, with Fade-in
</h3>
138 <button on-tap=
"{{preload}}" target=
"preload3afade">Load image
</button>
139 <span hidden?=
"{{!$.preload3afade.loading}}">Loading...
</span>
141 <core-image id=
"preload3afade" class=
"sized gray" preload
placeholder=
"data:image/gif;base64,R0lGODdhyADIAOMAAO7u/5aWlqGho9jY5OPj8cLCyqyssLe3vc3N1wAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAyADIAAAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS06kB1tYqA9cUBQEFrgLWAgIqBOEBFNuu1gMs2ugT3d/rAe0r77bsFwMGAQLzEggc8AcQAIJwA+EBuKbQmgF+3iocDHBAXiZ9Fd6dAxhuo4R3/gwnGDgnkqE1BBM0XrN3CSOFgQYM+ouHEsFMAP1i2lQIAN8EhwS6kZPQ74BMnpZcTgiHkoA1AhKxAWDaU+pHqwvrVVVI1ScmpRIwYjxwTqo+r1vTafV6FmtSrRXEak0ooB+8tjzR4v251m0llwSgUnUaAOrJtFMDoESrty9XxYi/wk0sMEBMoRKo7iRK8SiFxu285vQMoIDR0qdNN+rmbxxJlRFLi7u22OG1mDjP4bYb2uFVf+r0CZ+cyOS1oRD/cUM4cN5EA3bDhszqWOHEhBLIZh+qHdnmaFABwIwm9BxLZxAtn6fGvr379/Djy59Pv779+/jz69/Pv7///wAGQyjggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDRKEQEAOw==" fade
></core-image>
145 <button on-tap=
"{{preload}}" target=
"preload3bfade">Load image
</button>
146 <span hidden?=
"{{!$.preload3bfade.loading}}">Loading...
</span>
148 <core-image id=
"preload3bfade" class=
"sized gray" sizing=
"cover" preload
placeholder=
"data:image/gif;base64,R0lGODdhyADIAOMAAO7u/5aWlqGho9jY5OPj8cLCyqyssLe3vc3N1wAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAyADIAAAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS06kB1tYqA9cUBQEFrgLWAgIqBOEBFNuu1gMs2ugT3d/rAe0r77bsFwMGAQLzEggc8AcQAIJwA+EBuKbQmgF+3iocDHBAXiZ9Fd6dAxhuo4R3/gwnGDgnkqE1BBM0XrN3CSOFgQYM+ouHEsFMAP1i2lQIAN8EhwS6kZPQ74BMnpZcTgiHkoA1AhKxAWDaU+pHqwvrVVVI1ScmpRIwYjxwTqo+r1vTafV6FmtSrRXEak0ooB+8tjzR4v251m0llwSgUnUaAOrJtFMDoESrty9XxYi/wk0sMEBMoRKo7iRK8SiFxu285vQMoIDR0qdNN+rmbxxJlRFLi7u22OG1mDjP4bYb2uFVf+r0CZ+cyOS1oRD/cUM4cN5EA3bDhszqWOHEhBLIZh+qHdnmaFABwIwm9BxLZxAtn6fGvr379/Djy59Pv779+/jz69/Pv7///wAGQyjggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDRKEQEAOw==" fade
></core-image>
152 <button on-tap=
"{{preload}}" target=
"preload3cfade">Load image
</button>
153 <span hidden?=
"{{!$.preload3cfade.loading}}">Loading...
</span>
155 <core-image id=
"preload3cfade" class=
"sized gray" sizing=
"contain" preload
placeholder=
"data:image/gif;base64,R0lGODdhyADIAOMAAO7u/5aWlqGho9jY5OPj8cLCyqyssLe3vc3N1wAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAyADIAAAE/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TC6bz+i0es1uu9/wuHxOr9vv+Lx+z+/7/4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS06kB1tYqA9cUBQEFrgLWAgIqBOEBFNuu1gMs2ugT3d/rAe0r77bsFwMGAQLzEggc8AcQAIJwA+EBuKbQmgF+3iocDHBAXiZ9Fd6dAxhuo4R3/gwnGDgnkqE1BBM0XrN3CSOFgQYM+ouHEsFMAP1i2lQIAN8EhwS6kZPQ74BMnpZcTgiHkoA1AhKxAWDaU+pHqwvrVVVI1ScmpRIwYjxwTqo+r1vTafV6FmtSrRXEak0ooB+8tjzR4v251m0llwSgUnUaAOrJtFMDoESrty9XxYi/wk0sMEBMoRKo7iRK8SiFxu285vQMoIDR0qdNN+rmbxxJlRFLi7u22OG1mDjP4bYb2uFVf+r0CZ+cyOS1oRD/cUM4cN5EA3bDhszqWOHEhBLIZh+qHdnmaFABwIwm9BxLZxAtn6fGvr379/Djy59Pv779+/jz69/Pv7///wAGQyjggAQWaOCBCCao4IIMNujggxBGKOGEFFZo4YUYZqjhhhx26OGHIIYo4ogklmjiiSimqOKKLLbo4oswxijjjDRKEQEAOw==" fade
></core-image>
162 addEventListener('template-bound', function(e
) {
164 var scope
= e
.target
;
165 scope
.preload = function(e
) {
166 var img
= document
.querySelector('#' + e
.target
.getAttribute('target'));
167 img
.src
= 'http://lorempixel.com/1920/1080?' + Math
.random();
168 e
.target
.textContent
= 'Reload image';