-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathindex.html
executable file
·353 lines (353 loc) · 14.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Image Tilt Effect</title>
<meta name="description" content="A script for creating a tilt effect on an image that follows mouse movement" />
<meta name="keywords" content="tilt, image, effect, web design, mouse, movement" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.3.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="css/tilteffect.css" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<header class="codrops-header">
<div class="codrops-links">
<a class="codrops-icon codrops-icon--prev" href="http://tympanus.net/Development/TextStylesHoverEffects/" title="Previous Demo"><span>Previous Demo</span></a>
<a class="codrops-icon codrops-icon--drop" href="http://tympanus.net/codrops/?p=24116" title="Back to the article"><span>Back to the Codrops article</span></a>
</div>
<a class="github-link" href="https://github.com/codrops/ImageTiltEffect/"><i class="fa fa-github"></i><span>View on GitHub</span></a>
<div class="hero">
<div class="hero__imgwrap">
<img class="hero__img tilt-effect" data-tilt-options='{ "opacity" : 0.6, "movement": { "perspective" : 1500, "translateX" : 10, "translateY" : 10, "translateZ" : 2, "rotateX" : 3, "rotateY" : 3 } }' src="img/1.jpg" alt="Hero image" />
</div>
<h1><span>A subtle tilt effect for your images</span> Image Tilt Effect</h1>
<div class="mobile-note">This effect currently only works on hover. Please switch to a desktop browser in order to see the effect.</div>
</div>
</header><!-- /codrops-header -->
<div class="content">
<h2 class="poster-headline">How it works</h2>
<p class="poster-text">A normal image is replaced with layers of semi-transparent divisions of the same image. Every layer moves according to the configuration, creating a subtle motion effect.</p>
<p class="poster-text"><strong>Hover over the grid images to see how the effect works:</strong></p>
<ul class="grid grid--xray">
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" alt="grid01" />
</div>
<div class="grid__item-title">
Default options:
<pre><code>"extraImgs" : 2,
"opacity" : 0.7,
"bgfixed" : true,
"movement": {
"perspective" : 1000,
"translateX" : -10,
"translateY" : -10,
"translateZ" : 20,
"rotateX" : 2,
"rotateY" : 2,
"rotateZ" : 2
}</code></pre>
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "extraImgs" : 4, "opacity" : 0.5, "movement": { "perspective" : 500, "translateX" : -15, "translateY" : -15, "translateZ" : 20, "rotateX" : 15, "rotateY" : 15 } }' alt="grid01" />
</div>
<div class="grid__item-title">
Options:
<pre><code>"extraImgs" : 4,
"opacity" : 0.5,
"bgfixed" : true,
"movement": {
"perspective" : 500,
"translateX" : -15,
"translateY" : -15,
"translateZ" : 20,
"rotateX" : 15,
"rotateY" : 15
}</code></pre>
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "bgfixed" : false, "movement": { "perspective" : 1000, "translateX" : 30, "translateY" : 30, "translateZ" : -50, "rotateX" : 3, "rotateY" : 3, "rotateZ" : 10 } }' alt="grid01" />
</div>
<div class="grid__item-title">
Options:
<pre><code>"extraImgs" : 2,
"opacity" : 0.7,
"bgfixed" : false,
"movement": {
"perspective" : 1000,
"translateX" : 30,
"translateY" : 30,
"translateZ" : -50,
"rotateX" : 0,
"rotateY" : 0,
"rotateZ" : 10,
}</code></pre>
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "extraImgs" : 2, "extraImgsScaleGrade": -0.05, "opacity" : 0.7, "bgfixed" : false, "movement": { "perspective" : 1000, "translateX" : 30, "translateY" : 30, "translateZ" : -50, "rotateX" : 3, "rotateY" : 3, "rotateZ" : 10 } }' alt="grid01" />
</div>
<div class="grid__item-title">
Demo extraImgsScaleGrade. Options:
<pre><code>"extraImgs" : 2,
"extraImgsScaleGrade": -0.05,
"opacity" : 0.7,
"bgfixed" : false,
"movement": {
"perspective" : 1000,
"translateX" : 30,
"translateY" : 30,
"translateZ" : -50,
"rotateX" : 0,
"rotateY" : 0,
"rotateZ" : 10,
}</code></pre>
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "extraImgs" : 2, "opacity" : 0.7, "bgfixed" : false, "resetOnLeave" : false, "movement": { "perspective" : 1000, "translateX" : 30, "translateY" : 30, "translateZ" : -50, "rotateX" : 3, "rotateY" : 3, "rotateZ" : 10 } }' alt="grid01" />
</div>
<div class="grid__item-title">
Demo resetOnLeave. Options:
<pre><code>"extraImgs" : 2,
"opacity" : 0.7,
"bgfixed" : false,
"resetOnLeave" : false,
"movement": {
"perspective" : 1000,
"translateX" : 30,
"translateY" : 30,
"translateZ" : -50,
"rotateX" : 0,
"rotateY" : 0,
"rotateZ" : 10,
}</code></pre>
</div>
</li>
<li class="grid__item" id="demo-mouseMoveWatcher">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "extraImgs" : 2, "opacity" : 0.7, "bgfixed" : false, "movement": { "perspective" : 1000, "translateX" : 30, "translateY" : 30, "translateZ" : -50, "rotateX" : 3, "rotateY" : 3, "rotateZ" : 10 }, "element" : { "mouseMoveWatcher" : "#demo-mouseMoveWatcher" } }' alt="grid01" />
</div>
<div class="grid__item-title">
Demo element.mouseMoveWatcher. Options:
<pre><code>"extraImgs" : 2,
"opacity" : 0.7,
"bgfixed" : false,
"movement": {
"perspective" : 1000,
"translateX" : 30,
"translateY" : 30,
"translateZ" : -50,
"rotateX" : 0,
"rotateY" : 0,
"rotateZ" : 10,
},
"element" : {
"mouseMoveWatcher" : "#demo-mouseMoveWatcher",
}</code></pre>
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "extraImgs" : false, "bgfixed" : false, "movement": { "perspective" : 1000, "translateX" : 30, "translateY" : 30, "translateZ" : -50, "rotateX" : 3, "rotateY" : 3, "rotateZ" : 10 } }' alt="grid01" />
</div>
<div class="grid__item-title">
Demo without create ext images. Options:
<pre><code>"extraImgs" : false,
"bgfixed" : false,
"movement": {
"perspective" : 1000,
"translateX" : 30,
"translateY" : 30,
"translateZ" : -50,
"rotateX" : 0,
"rotateY" : 0,
"rotateZ" : 10,
}</code></pre>
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--border">
<img src="img/2.jpg" class="tilt-effect" data-tilt-options='{ "extraImgs" : 2, "opacity" : 0.7, "bgfixed" : false, "customImgsOpacity" : [0.2, 0.5, 0.03], "movement": { "perspective" : 1000, "translateX" : 30, "translateY" : 30, "translateZ" : -50, "rotateX" : 3, "rotateY" : 3, "rotateZ" : 10 } }' alt="grid01" />
</div>
<div class="grid__item-title">
Demo customImgsOpacity. Options:
<pre><code>"extraImgs" : 2,
"opacity" : 0.7,
"bgfixed" : false,
"customImgsOpacity" : [0.2, 0.5, 0.03],
"movement": {
"perspective" : 1000,
"translateX" : 30,
"translateY" : 30,
"translateZ" : -50,
"rotateX" : 0,
"rotateY" : 0,
"rotateZ" : 10,
}</code></pre>
</div>
</li>
</ul>
</div>
<div class="content">
<h2 class="poster-headline">Options</h2>
<p class="poster-text">A normal image is replaced with layers of semi-transparent divisions of the same image. Each layer gets moved in 3D, creating a subtle illusion of perspective.</p>
<dl class="def-list">
<dt><strong>extraImgs</strong></dt>
<dd>
<p>Number of extra background-image divisions; min:1, max:64</p>
<p><code>extraImgs : 2</code></p>
</dd>
<dt><strong>extraImgsScaleGrade</strong></dt>
<dd>
<p>Float number for set scale gradient. This option create effect like tunnel or add more perspective</p>
<p><code>extraImgsScaleGrade : 0</code></p>
</dd>
<dt><strong>opacity</strong></dt>
<dd>
<p>The opacity value for the background-image divisions</p>
<p><code>opacity : 0.7</code></p>
</dd>
<dt><strong>customImgsOpacity</strong></dt>
<dd>
<p>The customImgsOpacity make possible set custom opacity for each layer as array of opacity values.</p>
<p>If length of customImgsOpacity less then layers created then script will use option "opacity"</p>
<p><code>customImgsOpacity : false</code></p>
</dd>
<dt><strong>bgfixed</strong></dt>
<dd>
<p>Movement of first layer; by default it's not moving</p>
<p><code>bgfixed : true</code></p>
</dd>
<dt><strong>resetOnLeave</strong></dt>
<dd>
<p>If true when mouse leave detect area style of images will be reset to zero state</p>
<p><code>resetOnLeave : true</code></p>
</dd>
<dt><strong>movement</strong></dt>
<dd>
<p>The movemement configuration for each background-image division</p>
<p><code>movement : { ... }</code></p>
<dl class="def-list">
<dt><strong>perspective</strong></dt>
<dd>
<p>The perspective value for the 3D transforms</p>
<p><code>perspective : 1000</code></p>
</dd>
<dt><strong>translateX</strong></dt>
<dd>
<p>The relative movement on the x-axis. A positive value will move the background-image divisions in the same direction like the mouse up to the amount defined (in pixel). A negative value reverses the direction, i.e. moves the division into the opposite direction of the mouse.</p>
<p><code>translateX : -10</code></p>
</dd>
<dt><strong>translateY</strong></dt>
<dd>
<p>The relative movement on the y-axis.</p>
<p><code>translateY : -10</code></p>
</dd>
<dt><strong>translateZ</strong></dt>
<dd>
<p>The relative movement on the z-axis. This specific translation is done when the mouse moves vertically. A perspective value needs to be set.</p>
<p><code>translateZ : 20</code></p>
</dd>
<dt><strong>rotateX</strong></dt>
<dd>
<p>The relative rotation on the y-axis. A perspective value needs to be set.</p>
<p><code>rotateX : 2</code></p>
</dd>
<dt><strong>rotateY</strong></dt>
<dd>
<p>The relative rotation on the y-axis. A perspective value needs to be set.</p>
<p><code>rotateY : 2</code></p>
</dd>
<dt><strong>rotateZ</strong></dt>
<dd>
<p>The relative rotation on the Z-axis. A perspective value needs to be set.</p>
<p><code>rotateZ : 0</code></p>
</dd>
</dl>
</dd>
<dt><strong>element</strong></dt>
<dd>
<p>Element config make possible set detect area from css selectors</p>
<p><code>element : { ... }</code></p>
<dl class="def-list">
<dt><strong>mouseMoveWatcher</strong></dt>
<dd>
<p>The mouseMoveWatcher set css selector with element what catch mouse move events.</p>
<p>As example, you can set 'body' for detect mouse move on whole page</p>
<p><code>mouseMoveWatcher : null|string</code></p>
</dd>
<dt><strong>viewWatcher</strong></dt>
<dd>
<p>The viewWatcher is css selector for calculate element relative offsets of extra images.</p>
<p>As example, this may be one block of your page with height about 100vh</p>
<p><code>viewWatcher : null|string</code></p>
</dd>
</dl>
</dd>
</dl>
<p>Add the class "tilt-effect" to the respective image. The image container should have an explicit width and height.</p>
<p>To initialize either set the options in "data-tilt-options" or initialize with JavaScript: <code>new TiltFx(element, options)</code></p>
</div>
<div class="content">
<h2 class="poster-headline">Examples</h2>
<ul class="grid grid--examples">
<li class="grid__item">
<div class="grid__img grid__img--example-1" >
<img src="img/3.jpg" class="tilt-effect" alt="grid01" data-tilt-options='{ "opacity" : 0.3, "extraImgs" : 3, "movement": { "perspective" : 1200, "translateX" : -5, "translateY" : -5, "rotateX" : -5, "rotateY" : -5 } }' />
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--example-2">
<img src="img/4.jpg" class="tilt-effect" alt="grid02" data-tilt-options='{ "movement": { "perspective" : 700, "translateX" : -15, "translateY" : -15, "translateZ" : 10, "rotateX" : 2, "rotateY" : 10 } }' />
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--example-3">
<img src="img/5.jpg" class="tilt-effect" alt="grid03" data-tilt-options='{ "opacity" : 0.6, "extraImgs" : 4, "movement": { "perspective" : 500, "translateX" : 15, "translateY" : 0, "translateZ" : 10, "rotateX" : 3, "rotateY" : 4, "rotateZ" : 1 } }' />
</div>
</li>
<li class="grid__item">
<div class="grid__img grid__img--example-4">
<img src="img/6.jpg" class="tilt-effect" alt="grid04" data-tilt-options='{ "opacity" : 0.8, "bgfixed" : false, "extraImgs" : 3, "movement": { "perspective" : 1500, "translateX" : 80, "translateY" : 80, "translateZ" : 0, "rotateY" : 20 } }' />
</div>
</li>
</ul>
</div>
<div class="content">
<h2 class="poster-headline">Inspired by</h2>
<p class="poster-text"><a href="http://danielspatzek.com/">http://danielspatzek.com/</a></p>
<p class="poster-text"><a href="http://jviewz.com/#/dna">http://jviewz.com/#/dna</a></p>
<p class="poster-text"><a href="http://nclud.com/">http://nclud.com/</a></p>
</div>
<!-- Related demos -->
<section class="content content--related">
<h2 class="poster-headline">Related demos:</h2>
<a class="media-item" href="http://tympanus.net/Development/PhotographyWebsiteConcept/">
<img class="media-item__img" src="img/related/PhotographyWebsiteConcept.jpg">
<h3 class="media-item__title">Photography Website Concept</h3>
</a>
<a class="media-item" href="http://tympanus.net/Tutorials/PrismEffectSlider/">
<img class="media-item__img" src="img/related/PrismEffectSlider.jpg">
<h3 class="media-item__title">Prism Effect Slider</h3>
</a>
</section>
</div><!-- /container -->
<script src="js/tiltfx.js"></script>
</body>
</html>