|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Basic Features of the ImageLoader Utility</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<h1>Example: Basic Features of the ImageLoader Utility</h1> |
|
|
25 |
<div class="yui3-g"> |
|
|
26 |
<div class="yui3-u-3-4"> |
|
|
27 |
<div id="main"> |
|
|
28 |
<div class="content"><div class="intro"> |
|
|
29 |
<p> |
|
|
30 |
Displayed here are some basic triggers of the ImageLoader Utility. |
|
|
31 |
Each image group has an assigned action that will make the group of image(s) appear. |
|
|
32 |
</p> |
|
|
33 |
</div> |
|
|
34 |
|
|
|
35 |
<style> |
|
|
36 |
#group1, #group2, #group3, #group4 { border-bottom: dotted 2px #ccc;} |
|
|
37 |
.yuiLogo { width:117px; height: 52px; border:1px solid #888; margin:5px;} |
|
|
38 |
</style> |
|
|
39 |
|
|
|
40 |
|
|
|
41 |
<div id="group1"> |
|
|
42 |
<h2>Group 1: Two second delay</h2> |
|
|
43 |
<p>This will appear two seconds after page-load.</p> |
|
|
44 |
<div class='example'> |
|
|
45 |
<div class='yuiLogo' id='delay' title='Group 1: 2 sec limit'></div> |
|
|
46 |
</div> |
|
|
47 |
|
|
|
48 |
<h5>HTML</h5> |
|
|
49 |
<pre class="code prettyprint"><div id='delay' title='Group 1: 2 sec limit'></div></pre> |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
<h5>JavaScript</h5> |
|
|
53 |
<pre class="code prettyprint">var delayGroup = new Y.ImgLoadGroup({ timeLimit: 2 }); |
|
|
54 |
delayGroup.registerImage({ domId: 'delay', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true });</pre> |
|
|
55 |
|
|
|
56 |
</div> |
|
|
57 |
|
|
|
58 |
<div id="group2"> |
|
|
59 |
<h2>Group 2: Window scroll event</h2> |
|
|
60 |
<p>This will appear when the scroll event is fired.</p> |
|
|
61 |
<div class='example'> |
|
|
62 |
<div class='yuiLogo' title='Group 2: scroll'> |
|
|
63 |
<img id='scroll' style='visibility:hidden;' /> |
|
|
64 |
</div> |
|
|
65 |
</div> |
|
|
66 |
|
|
|
67 |
<h5>HTML</h5> |
|
|
68 |
<pre class="code prettyprint"><img id='scroll' style='visibility:hidden;' /></pre> |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
<h5>JavaScript</h5> |
|
|
72 |
<pre class="code prettyprint">var scrollGroup = new Y.ImgLoadGroup(); |
|
|
73 |
scrollGroup.registerImage({ domId: 'scroll', srcUrl: '../assets/imageloader/yui-logo.png', isPng: true, setVisible: true }); |
|
|
74 |
scrollGroup.addTrigger(window, 'scroll');</pre> |
|
|
75 |
|
|
|
76 |
</div> |
|
|
77 |
|
|
|
78 |
<div id="group3"> |
|
|
79 |
<h2>Group 3: Mouse over</h2> |
|
|
80 |
<p>This will appear when you mouse over it.</p> |
|
|
81 |
<div class="example"> |
|
|
82 |
<div class='yuiLogo' id='mouseover' title='Group 3: mouseover'></div> |
|
|
83 |
</div> |
|
|
84 |
|
|
|
85 |
<h5>HTML</h5> |
|
|
86 |
<pre class="code prettyprint"><div id='mouseover' title='Group 3: mouseover'></div></pre> |
|
|
87 |
|
|
|
88 |
|
|
|
89 |
<h5>JavaScript</h5> |
|
|
90 |
<pre class="code prettyprint">var mouseoverGroup = new Y.ImgLoadGroup(); |
|
|
91 |
mouseoverGroup.registerImage({ domId: 'scroll', srcUrl: '../assets/imageloader/yui-logo.png', isPng: true, setVisible: true }); |
|
|
92 |
mouseoverGroup.addTrigger(window, 'scroll');</pre> |
|
|
93 |
|
|
|
94 |
</div> |
|
|
95 |
|
|
|
96 |
<div id="group4"> |
|
|
97 |
<h2>Group 4: Onclick</h2> |
|
|
98 |
<p>These will appear when either one is clicked.</p> |
|
|
99 |
<div class="example"> |
|
|
100 |
<div class='yuiLogo' id='duo1' title='Group 4: onclick'></div> |
|
|
101 |
<div class='yuiLogo' id='duo2' title='Group 4: onclick'></div> |
|
|
102 |
</div> |
|
|
103 |
|
|
|
104 |
<h5>HTML</h5> |
|
|
105 |
<pre class="code prettyprint"><div id='duo1' title='Group 4: onclick'></div> |
|
|
106 |
<div id='duo2' title='Group 4: onclick'></div></pre> |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
<h5>JavaScript</h5> |
|
|
110 |
<pre class="code prettyprint">var clickGroup = new Y.ImgLoadGroup(); |
|
|
111 |
clickGroup.registerImage({ domId: 'duo1', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true }); |
|
|
112 |
clickGroup.registerImage({ domId: 'duo2', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true }); |
|
|
113 |
clickGroup.addTrigger('#duo2', 'click').addTrigger('#duo1', 'click');</pre> |
|
|
114 |
|
|
|
115 |
</div> |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
<script> |
|
|
120 |
|
|
|
121 |
YUI().use("imageloader", function(Y) { |
|
|
122 |
|
|
|
123 |
var delayGroup = new Y.ImgLoadGroup({ timeLimit: 2 }); |
|
|
124 |
delayGroup.registerImage({ domId: 'delay', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true }); |
|
|
125 |
|
|
|
126 |
var scrollGroup = new Y.ImgLoadGroup(); |
|
|
127 |
scrollGroup.addTrigger(window, 'scroll'); |
|
|
128 |
scrollGroup.registerImage({ domId: 'scroll', srcUrl: '../assets/imageloader/yui-logo.png', isPng: true, setVisible: true }); |
|
|
129 |
|
|
|
130 |
var mouseoverGroup = new Y.ImgLoadGroup(); |
|
|
131 |
mouseoverGroup.addTrigger('#mouseover', 'mouseover'); |
|
|
132 |
mouseoverGroup.registerImage({ domId: 'mouseover', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true }); |
|
|
133 |
|
|
|
134 |
var clickGroup = new Y.ImgLoadGroup(); |
|
|
135 |
clickGroup.addTrigger('#duo2', 'click').addTrigger('#duo1', 'click'); |
|
|
136 |
clickGroup.registerImage({ domId: 'duo1', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true }); |
|
|
137 |
clickGroup.registerImage({ domId: 'duo2', bgUrl: '../assets/imageloader/yui-logo.png', isPng: true }); |
|
|
138 |
|
|
|
139 |
}); |
|
|
140 |
|
|
|
141 |
</script> |
|
|
142 |
|
|
|
143 |
<!-- |
|
|
144 |
<h2>Basic Features of the ImageLoader Utility</h2> |
|
|
145 |
|
|
|
146 |
<p> |
|
|
147 |
The ImageLoader Utility allows you to define the conditions under which images are loaded into the page. |
|
|
148 |
This example demonstrates attaching some simple triggers to images to establish this load control. |
|
|
149 |
</p> |
|
|
150 |
|
|
|
151 |
<p> |
|
|
152 |
The HTML used for the image needs little to no modification. |
|
|
153 |
Simply make sure the <code><img></code> elements have <code>id</code> attributes, eliminate the <code>src</code> attribute |
|
|
154 |
from <code><img></code> elements, and optionally set their <code>visibility</code> style to "hidden" . |
|
|
155 |
|
|
|
156 |
<pre class="code prettyprint"><img id='image' style='visibility:hidden;' /></pre> |
|
|
157 |
|
|
|
158 |
</p> |
|
|
159 |
--></div> |
|
|
160 |
</div> |
|
|
161 |
</div> |
|
|
162 |
|
|
|
163 |
<div class="yui3-u-1-4"> |
|
|
164 |
<div class="sidebar"> |
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
<div class="sidebox"> |
|
|
169 |
<div class="hd"> |
|
|
170 |
<h2 class="no-toc">Examples</h2> |
|
|
171 |
</div> |
|
|
172 |
|
|
|
173 |
<div class="bd"> |
|
|
174 |
<ul class="examples"> |
|
|
175 |
|
|
|
176 |
|
|
|
177 |
<li data-description="Demonstrates the basic features and operation of the ImageLoader Utility, deferring the loading of images until specific events happen or specific time limits expire."> |
|
|
178 |
<a href="basic-features.html">Basic Features of the ImageLoader Utility</a> |
|
|
179 |
</li> |
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
<li data-description="Loading images above the fold immediately while deferring the loading of images below the fold."> |
|
|
184 |
<a href="below-fold.html">Loading Images Below the Fold</a> |
|
|
185 |
</li> |
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
<li data-description="Using CSS class names to target specific images for deferred loading."> |
|
|
190 |
<a href="imageloader-class-names.html">Using ImageLoader with CSS Class Names</a> |
|
|
191 |
</li> |
|
|
192 |
|
|
|
193 |
|
|
|
194 |
</ul> |
|
|
195 |
</div> |
|
|
196 |
</div> |
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
</div> |
|
|
201 |
</div> |
|
|
202 |
</div> |
|
|
203 |
</div> |
|
|
204 |
|
|
|
205 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
206 |
<script>prettyPrint();</script> |
|
|
207 |
|
|
|
208 |
<script> |
|
|
209 |
YUI.Env.Tests = { |
|
|
210 |
examples: [], |
|
|
211 |
project: '../assets', |
|
|
212 |
assets: '../assets/imageloader', |
|
|
213 |
name: 'basic-features', |
|
|
214 |
title: 'Basic Features of the ImageLoader Utility', |
|
|
215 |
newWindow: '', |
|
|
216 |
auto: false |
|
|
217 |
}; |
|
|
218 |
YUI.Env.Tests.examples.push('basic-features'); |
|
|
219 |
YUI.Env.Tests.examples.push('below-fold'); |
|
|
220 |
YUI.Env.Tests.examples.push('imageloader-class-names'); |
|
|
221 |
|
|
|
222 |
</script> |
|
|
223 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
</body> |
|
|
228 |
</html> |