Skip to content

Commit 6b1687d

Browse files
author
daniel-lundin
committed
Fix vendor prefixes, fix perspective, linted docs.js
1 parent 8cce8e9 commit 6b1687d

File tree

9 files changed

+106
-106
lines changed

9 files changed

+106
-106
lines changed

docs/cards.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ function rotateContainer() {
120120
duration: 10000,
121121
perspective: 2000,
122122
complete: function() {
123-
console.log('compoete');
124123
rotateContainer();
125124
}
126125
});

docs/docs.js

Lines changed: 95 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
/* global $, window, document, snabbt, Hammer, FastClick*/
2+
'use strict';
13
$(function() {
24

3-
var title = $("h1").text();
4-
var titleHeight = $("h1").height();
55

66
// Title animation
7-
$("h1 span").snabbt({
8-
fromRotation: [0, 0, -8*Math.PI],
7+
$('h1 span').snabbt({
8+
fromRotation: [0, 0, -8 * Math.PI],
99
delay: function(i) {
1010
return 1000 + i * 100;
1111
},
1212
duration: 1000,
1313
easing: 'ease',
1414
complete: function(i, length) {
15-
if(i === length - 1) {
16-
$("h1").snabbt({
15+
if (i === length - 1) {
16+
$('h1').snabbt({
1717
transformOrigin: [0, 100, 0],
18-
rotation: [-Math.PI/4, 0, 0],
18+
rotation: [-Math.PI / 4, 0, 0],
1919
perspective: 300,
2020
easing: 'linear',
2121
delay: 400,
@@ -27,39 +27,39 @@ $(function() {
2727
perspective: 300,
2828
springConstant: 0.2,
2929
springDeceleration: 0.90,
30-
springMass: 4,
30+
springMass: 4
3131
});
3232
}
3333
}
3434
});
3535

3636
// Title easter egg
37-
$("h1").on('click', function() {
38-
var width = $("h1").width();
39-
$("h1").snabbt({
37+
$('h1').on('click', function() {
38+
var width = $('h1').width();
39+
$('h1').snabbt({
4040
fromPosition: [0, 0, 0],
4141
skew: [0, 0.9],
42-
easing: 'ease',
42+
easing: 'ease'
4343
}).snabbt({
44-
position: [2*width, 0, 0],
44+
position: [2 * width, 0, 0],
4545
skew: [0, 0],
4646
easing: 'easeIn',
47-
duration: 200,
47+
duration: 200
4848
}).snabbt({
49-
transformOrigin: [-width/2, 0, 0],
49+
transformOrigin: [-width / 2, 0, 0],
5050
rotation: [0, -Math.PI, 0],
51-
fromPosition: [2*width, 0, 0],
52-
position: [2*width, 0, 0],
51+
fromPosition: [2 * width, 0, 0],
52+
position: [2 * width, 0, 0],
5353
perspective: 500,
5454
easing: 'ease',
55-
delay: 200,
55+
delay: 200
5656
}).snabbt({
57-
transformOrigin: [width/2, 0, 0],
57+
transformOrigin: [width / 2, 0, 0],
5858
rotation: [0, 0, 0],
5959
fromPosition: [0, 0, 0],
6060
position: [0, 0, 0],
6161
perspective: 500,
62-
easing: 'ease',
62+
easing: 'ease'
6363
});
6464
});
6565

@@ -79,56 +79,57 @@ $(function() {
7979
easing: 'ease'
8080
}).snabbt({
8181
position: [0, 0, 0],
82-
fromRotation: [0, 0, -2*Math.PI],
82+
fromRotation: [0, 0, -2 * Math.PI],
8383
rotation: [0, 0, 0],
8484
easing: 'spring',
8585
springConstant: 0.2,
8686
springDeceleration: 0.90,
87-
springMass: 10,
87+
springMass: 10
8888
});
8989
};
9090

9191
// Easings
9292
var easingDemos = document.querySelectorAll('.easing-demo');
93-
for(var i=0;i<easingDemos.length;++i) {
94-
var container = easingDemos[i];
93+
var container;
94+
for (var i = 0; i < easingDemos.length; ++i) {
95+
container = easingDemos[i];
9596
var easingName = container.attributes['data-easing-name'];
9697
var element = container.children[0];
97-
container.onclick = function(container, element, easingName) {
98-
var containerWidth = container.offsetWidth;
99-
var elementWidth = element.offsetWidth;
100-
snabbt(element, {
98+
container.addEventListener('click', function(_container, _element, _easingName) {
99+
var containerWidth = _container.offsetWidth;
100+
var elementWidth = _element.offsetWidth;
101+
snabbt(_element, {
101102
fromPosition: [0, 0, 0],
102103
position: [containerWidth - elementWidth, 0, 0],
103-
easing: easingName.value,
104+
easing: _easingName.value,
104105
duration: 500
105106
});
106-
}.bind(undefined, container, element, easingName);
107+
}.bind(null, container, element, easingName));
107108
}
108109

109110
// Spring easings
110-
$("#spring-example").on('click', function() {
111-
$("#spring-example").snabbt({
111+
$('#spring-example').on('click', function() {
112+
$('#spring-example').snabbt({
112113
position: [100, 0, 0],
113114
fromRotation: [0, 0, 0],
114-
rotation: [0, 0, 2*Math.PI],
115+
rotation: [0, 0, 2 * Math.PI],
115116
easing: 'spring',
116117
springConstant: 0.3,
117-
springDeceleration: 0.8,
118+
springDeceleration: 0.8
118119
}).snabbt({
119120
position: [0, 0, 0],
120121
easing: 'spring',
121122
springConstant: 0.3,
122-
springDeceleration: 0.8,
123+
springDeceleration: 0.8
123124
});
124125
});
125126

126127
// Custom easing
127-
$("#custom-easer").on('click', function() {
128-
$("#custom-easer").snabbt({
128+
$('#custom-easer').on('click', function() {
129+
$('#custom-easer').snabbt({
129130
position: [200, 0, 0],
130131
easing: function(value) {
131-
return value + 0.3 * Math.sin(2*Math.PI * value);
132+
return value + 0.3 * Math.sin(2 * Math.PI * value);
132133
}
133134
}).snabbt({
134135
position: [0, 0, 0],
@@ -137,91 +138,89 @@ $(function() {
137138
});
138139

139140
// Value feed example
140-
$("#value-feed-example").on('click', function() {
141-
$("#value-feed-example").snabbt({
142-
valueFeeder: function(i, matrix) {
143-
var x = Math.sin(i*Math.PI);
144-
return matrix.rotateZ(Math.sin(6*i*Math.PI)).translate(x*200, 0, 0);
141+
$('#value-feed-example').on('click', function() {
142+
$('#value-feed-example').snabbt({
143+
valueFeeder: function(value, matrix) {
144+
var x = Math.sin(value * Math.PI);
145+
return matrix.rotateZ(Math.sin(6 * value * Math.PI)).translate(x * 200, 0, 0);
145146
},
146-
duration: 1000,
147+
duration: 1000
147148
});
148149
});
149150

150151
// Transform origin example
151-
$("#transform-origin-example").on('click', function() {
152-
var elementWidth = $("#transform-origin-example").outerWidth();
153-
$("#transform-origin-example").snabbt({
152+
$('#transform-origin-example').on('click', function() {
153+
var elementWidth = $('#transform-origin-example').outerWidth();
154+
$('#transform-origin-example').snabbt({
154155
fromRotation: [0, 0, 0],
155-
rotation: [0, 2*Math.PI, 0],
156-
transformOrigin: [elementWidth/2, 0, 0],
157-
perspective: 400,
156+
rotation: [0, 2 * Math.PI, 0],
157+
transformOrigin: [elementWidth / 2, 0, 0],
158+
perspective: 400
158159
});
159160
});
160161

161162
// Transform origin example
162-
$("#transform-origin-example-2").on('click', function() {
163-
var elementWidth = $("#transform-origin-example-2").outerWidth();
164-
$("#transform-origin-example-2").snabbt({
163+
$('#transform-origin-example-2').on('click', function() {
164+
var elementWidth = $('#transform-origin-example-2').outerWidth();
165+
$('#transform-origin-example-2').snabbt({
165166
rotation: [0, Math.PI, 0],
166-
transformOrigin: [elementWidth/2, 0, 0],
167+
transformOrigin: [elementWidth / 2, 0, 0],
167168
perspective: 400,
168169
duration: 300,
169170
easing: 'ease'
170171
}).snabbt({
171-
fromPosition: [2*elementWidth, 0, 0],
172-
position: [2*elementWidth, 0, 0],
172+
fromPosition: [2 * elementWidth, 0, 0],
173+
position: [2 * elementWidth, 0, 0],
173174
fromRotation: [0, -Math.PI, 0],
174175
rotation: [0, 0, 0],
175-
transformOrigin: [-elementWidth/2, 0, 0],
176+
transformOrigin: [-elementWidth / 2, 0, 0],
176177
perspective: 400,
177178
duration: 300,
178179
easing: 'ease'
179180
}).snabbt({
180181
fromRotation: [0, 0, 0],
181-
fromPosition: [2*elementWidth, 0, 0],
182+
fromPosition: [2 * elementWidth, 0, 0],
182183
position: [0, 0, 0],
183184
duration: 300,
184185
easing: 'ease'
185186
});
186187
});
187188

188-
189-
190189
// Attention example
191-
$("#attention-example-1").on('click', function() {
192-
$("#attention-example-1").snabbt("attention", {
193-
rotation: [0, 0, Math.PI/2],
190+
$('#attention-example-1').on('click', function() {
191+
$('#attention-example-1').snabbt('attention', {
192+
rotation: [0, 0, Math.PI / 2],
194193
springConstant: 1.9,
195-
springDeceleration: 0.9,
194+
springDeceleration: 0.9
196195
});
197196
});
198197

199198
// Attention example
200-
$("#attention-example-2").on('click', function() {
201-
$("#attention-example-2").snabbt("attention", {
199+
$('#attention-example-2').on('click', function() {
200+
$('#attention-example-2').snabbt('attention', {
202201
position: [50, 0, 0],
203202
springConstant: 2.4,
204-
springDeceleration: 0.9,
203+
springDeceleration: 0.9
205204
});
206205
});
207206

208207
// Multi element animation
209-
$("#multi-element-example").on('click', function() {
210-
$(".multi-example").snabbt({
208+
$('#multi-element-example').on('click', function() {
209+
$('.multi-example').snabbt({
211210
fromRotation: [0, 0, 0],
212-
rotation: function(i, total) {
213-
return [0, 0, (i/(total - 1)) * (Math.PI/2)];
211+
rotation: function(value, total) {
212+
return [0, 0, value / (total - 1) * (Math.PI / 2)];
214213
},
215-
delay: function(i) {
216-
return i * 50;
214+
delay: function(index) {
215+
return index * 50;
217216
},
218-
easing: 'spring',
217+
easing: 'spring'
219218
}).snabbt({
220219
rotation: [0, 0, 0],
221-
delay: function(i, total) {
222-
return (total - i - 1) * 50;
220+
delay: function(index, total) {
221+
return (total - index - 1) * 50;
223222
},
224-
easing: 'ease',
223+
easing: 'ease'
225224
});
226225
});
227226

@@ -247,7 +246,7 @@ $(function() {
247246
animations.push(snabbt(flipperBackground, {
248247
fromScale: [0.0, 0.0],
249248
scale: [1.0, 1.0],
250-
fromRotation: [0, 0, 2*Math.PI],
249+
fromRotation: [0, 0, 2 * Math.PI],
251250
rotation: [0, 0, 0],
252251
manual: true,
253252
easing: 'ease',
@@ -269,7 +268,7 @@ $(function() {
269268
animations.push(snabbt(flipperBackground, {
270269
scale: [0.0, 0.0],
271270
fromRotation: [0, 0, 0],
272-
rotation: [0, 0, 2*Math.PI],
271+
rotation: [0, 0, 2 * Math.PI],
273272
manual: true,
274273
easing: 'ease',
275274
duration: 1000
@@ -282,7 +281,7 @@ $(function() {
282281
var n = number;
283282
return function() {
284283
n--;
285-
if(n === 0) {
284+
if (n === 0) {
286285
callback();
287286
}
288287
};
@@ -293,26 +292,26 @@ $(function() {
293292
var opened = -1;
294293
var animations = [];
295294
hammer.on('pan', function(event) {
296-
if(!dragInProgress) {
297-
if(opened === -1) {
295+
if (!dragInProgress) {
296+
if (opened === -1) {
298297
animations = dragRightAnimations();
299298
} else {
300299
animations = dragLeftAnimations();
301300
}
302301
dragInProgress = true;
303302
}
304303

305-
var delta = Math.min(1, Math.max(0, (-opened * event.deltaX)/200));
306-
if(animations.length) {
304+
var delta = Math.min(1, Math.max(0, -opened * event.deltaX / 200));
305+
if (animations.length) {
307306
animations.forEach(function(animation) {
308307
animation.setValue(delta);
309308
});
310309
}
311310

312311

313-
if(event.isFinal) {
314-
if(animations) {
315-
if(delta > 0.5) {
312+
if (event.isFinal) {
313+
if (animations) {
314+
if (delta > 0.5) {
316315
var finishCallback = debouncedCallback(function() {
317316
dragInProgress = false;
318317
opened *= -1;
@@ -337,19 +336,19 @@ $(function() {
337336
})();
338337

339338
// Scroll spy
340-
var navtop = $("#navbar").offset().top;
341-
var $dockedNavbar = $("#docked-navbar");
339+
var navtop = $('#navbar').offset().top;
340+
var $dockedNavbar = $('#docked-navbar');
342341
var $window = $(window);
343-
$(window).on('scroll', function(event) {
344-
if($window.scrollTop() > navtop) {
345-
if($dockedNavbar.hasClass('hidden'))
346-
$("#docked-navbar").removeClass("hidden");
342+
$(window).on('scroll', function() {
343+
if ($window.scrollTop() > navtop) {
344+
if ($dockedNavbar.hasClass('hidden'))
345+
$('#docked-navbar').removeClass('hidden');
347346
} else {
348-
if(!$dockedNavbar.hasClass('hidden'))
349-
$("#docked-navbar").addClass("hidden");
347+
if (!$dockedNavbar.hasClass('hidden'))
348+
$('#docked-navbar').addClass('hidden');
350349
}
351350
});
352351

353352
FastClick.attach(document.body);
354353

355-
}());
354+
})();

0 commit comments

Comments
 (0)