scrolld.js-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a8bbac7d1a676da145880c19a5c4e18371ab1034
4
+ data.tar.gz: 818d421337872e6dd4a8ae57ef39ed5fa98e6312
5
+ SHA512:
6
+ metadata.gz: 87190066719e596d94584d321716370077f9a60b1da0a809c646b6330c8c57c587521a299d4a93c38a8aa6c56399447401fd2b055a21c091ec9c45acf5ca0fc5
7
+ data.tar.gz: cf39843e2f2b984677f9dd83530bceea7996deab3ab3f02bcd3e5917c7de75a0aca8fd0299e874cb3dad06a3259812a74003a980f367d601fe50bf4248f5952a
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Trevor Strieber
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # scrolld.js-rails
2
+
3
+ This gem packages [Scrolld.js](https://github.com/charliegeiger89/Scrolld.js) for the Rails 3.1+ asset pipeline.
4
+
5
+ Scrolld.js requires `jQuery 1.7.x+`.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+ ```
11
+ gem 'scrolld.js-rails', '~> 1.0.0'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install scrolld.js-rails
22
+ ```
23
+
24
+ Add the following to your JavaScript manifest file (`application.js`):
25
+
26
+ ```js
27
+ //= require scrolld
28
+ ```
29
+
30
+ or
31
+
32
+ ```js
33
+ //= require scrolld.min
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Check out the documentation at: http://www.scrolldjs.com/
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it ( http://github.com/TrevorS/scrolld.js-rails/fork )
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ require "scrolld.js-rails/version"
2
+
3
+ module ScrolldJs
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module ScrolldJs
2
+ module Rails
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,513 @@
1
+ (function ($) {
2
+ $.fn.scrolld = function (options) {
3
+ var scrolldCustom = 0; // Set 'scrolldCustom' value here | Additional distance (+-) on scrolldTop & scrolldPre
4
+ var scrolldNavBar = 'fixedNavBar'; // Set id name of fixed web navbar
5
+ var scrolldMobileNavBar = 'fixedNavBar'; // Set id name of fixed mobile navbar
6
+
7
+ // DO NOT TOUCH // MOVE DOWN TO DEFAULTS //
8
+ // Set Scrolld Heavily Used Variables //
9
+ var $win = $(window);
10
+ var doc = document;
11
+ var y = $win.scrollTop();
12
+ var h = $win.height();
13
+ var x = $win.width();
14
+ var htmlBody = $('html, body');
15
+ // Trigger Win Scroll Function
16
+ $win.scroll(function (e) {
17
+ y = $win.scrollTop(); // Update y value dynamically
18
+ e.stopImmediatePropagation() // Kill For Next Click
19
+ return false;
20
+ });
21
+ // Trigger Win Resize Function
22
+ $win.resize(function (e) {
23
+ h = $win.height(); // Update h value dynamically
24
+ x = $win.width(); // Update x value dynamically
25
+ e.stopImmediatePropagation() // Kill For Next Click
26
+ return false;
27
+ });
28
+ // Custom Easing Function | Slow & Smooth
29
+ $.easing.scrolldEasing1 = function (x, t, b, c, d) {
30
+ var ts = (t /= d) * t;
31
+ var tc = ts * t;
32
+ return b + c * (-3.6 * tc * ts + 4.3 * ts * ts + 0.2 * tc + 0.1 * ts);
33
+ };
34
+ // Custom Easing Function | Elastic
35
+ $.easing.scrolldEasing2 = function (x, t, b, c, d) {
36
+ var ts = (t /= d) * t;
37
+ var tc = ts * t;
38
+ return b + c * (18.9925 * tc * ts + -45.23 * ts * ts + 40.28 * tc + -19.89 * ts + 6.8475 * t);
39
+ };
40
+ // Custom Easing Function | Bouncy
41
+ $.easing.scrolldEasing3 = function (x, t, b, c, d) {
42
+ if ((t /= d) < (1.25 / 3)) {
43
+ return c * (9.5625 * t * t) + b;
44
+ } else if (t < (2.25 / 3)) {
45
+ return c * (8.5625 * (t -= (1.5 / 2.75)) * t + .85) + b;
46
+ } else if (t < (2.75 / 3)) {
47
+ return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
48
+ } else {
49
+ return c * (5.5625 * (t -= (2.625 / 2.75)) * t + 1) + b;
50
+ }
51
+ };
52
+ // Set Speed Vars For Easy Customization
53
+ var speed1 = 100;
54
+ var speed2 = 200;
55
+ var speed3 = 300;
56
+ var speed4 = 400;
57
+ var speed5 = 500;
58
+ var speed6 = 600;
59
+ var speed7 = 700;
60
+ var speed8 = 800;
61
+ var speed9 = 900;
62
+ var speed10 = 1000;
63
+ var speed11 = 1100;
64
+ var speed12 = 1200;
65
+ var speed13 = 1300;
66
+ var speed14 = 1400;
67
+ var speed15 = 1500;
68
+ var speed16 = 1600;
69
+ var speed17 = 1700;
70
+ var speed18 = 1800;
71
+ var speed19 = 1900;
72
+ var speed20 = 2000;
73
+ var speedX = 3000;
74
+ // Define scrolling functions / Maths
75
+ var idScroll = $(this).attr('id');
76
+ var scrolldFixed = $("#" + scrolldNavBar).outerHeight();
77
+ var scrolldMobileFixed = $("#" + scrolldMobileNavBar).outerHeight();
78
+ var idScrollElement = $("#" + idScroll);
79
+ var idScrollString = idScroll.substr(0, idScroll.length - 3);
80
+ var idScrollDiv = document.getElementById(idScrollString).id;
81
+ var idScrollDivElement = $("#" + idScrollDiv);
82
+ var offsetDivElementTop = Math.round(idScrollDivElement.offset().top);
83
+ var idScrollDivElementHeight = Math.round(idScrollDivElement.height());
84
+ var scrolldTop = offsetDivElementTop + scrolldCustom;
85
+ var scrolldTopFixed = Math.round(offsetDivElementTop - scrolldFixed) + scrolldCustom;
86
+ var scrolldPre = offsetDivElementTop - Math.round(h / 15) + scrolldCustom;
87
+ var scrolldPreFixed = offsetDivElementTop - scrolldFixed - Math.round(h / 20) + scrolldCustom;
88
+ var scrolldCenter = offsetDivElementTop - Math.round(h / 2 - idScrollDivElementHeight / 2);
89
+ var scrolldMobileTopFixed = Math.round(offsetDivElementTop - scrolldMobileFixed) + scrolldCustom;
90
+ var scrolldMobilePreFixed = offsetDivElementTop - scrolldMobileFixed - Math.round(h / 20) + scrolldCustom;
91
+ // Set Vars For Customization
92
+ var scrolldDistance = scrolldTop;
93
+ var scrolldDistanceMin = scrolldTop;
94
+ var scrolldSpeed = speed11;
95
+ var scrolldEasing = 'scrolldEasing1';
96
+ var scrolldFixed = true;
97
+ var scrolldMobile = true;
98
+ var scrolldMobileWidth = 979;
99
+ var scrolldMobileDistance = scrolldTop;
100
+ var scrolldMobileDistanceMin = scrolldTop;
101
+ var scrolldMobileSpeed = speed11;
102
+ var scrolldMobileEasing = 'scrolldEasing1';
103
+ var scrolldMobileFixed = true;
104
+
105
+ // SET CUSTOM SETTINGS HERE //
106
+ var
107
+ defaults = {
108
+ /// Set Web Settings
109
+ scrolldDistance: scrolldPre,
110
+ scrolldDistanceMin: scrolldPre,
111
+ scrolldSpeed: speed11,
112
+ scrolldEasing: 'scrolldEasing1',
113
+ scrolldFixed: 'true',
114
+ /// Set Mobile Settings
115
+ scrolldMobile: 'true',
116
+ scrolldMobileWidth: 979,
117
+ scrolldMobileDistance: scrolldPre,
118
+ scrolldMobileDistanceMin: scrolldPre,
119
+ scrolldMobileSpeed: speed11,
120
+ scrolldMobileEasing: 'scrolldEasing1',
121
+ scrolldMobileFixed: 'true'
122
+ },
123
+ // DO NOT TOUCH // NO OTHER INPUTS NEEDED //
124
+ settings = $.extend({}, defaults, options);
125
+ this.each(function () {
126
+ if ($(this).attr('id') != '') {
127
+ var $this = $(this);
128
+ // Multiple IF's For Easy Customization
129
+ if (settings.scrolldDistance) {
130
+ scrolldDistance = settings.scrolldDistance;
131
+ }
132
+ if (settings.scrolldDistanceMin) {
133
+ scrolldDistanceMin = settings.scrolldDistanceMin;
134
+ }
135
+ if (settings.scrolldSpeed) {
136
+ scrolldSpeed = settings.scrolldSpeed;
137
+ }
138
+ if (settings.scrolldEasing) {
139
+ scrolldEasing = settings.scrolldEasing;
140
+ }
141
+ if (settings.scrolldFixed === 'false') {
142
+ scrolldFixed = false;
143
+ }
144
+ if (settings.scrolldMobile === 'false') {
145
+ scrolldMobile = false;
146
+ }
147
+ if (settings.scrolldMobileWidth) {
148
+ scrolldMobileWidth = settings.scrolldMobileWidth;
149
+ }
150
+ if (settings.scrolldMobileDistance) {
151
+ scrolldMobileDistance = settings.scrolldMobileDistance;
152
+ }
153
+ if (settings.scrolldMobileDistanceMin) {
154
+ scrolldMobileDistanceMin = settings.scrolldMobileDistanceMin;
155
+ }
156
+ if (settings.scrolldMobileSpeed) {
157
+ scrolldMobileSpeed = settings.scrolldMobileSpeed;
158
+ }
159
+ if (settings.scrolldMobileEasing) {
160
+ scrolldMobileEasing = settings.scrolldMobileEasing;
161
+ }
162
+ if (settings.scrolldMobileFixed === 'false') {
163
+ scrolldMobileFixed = false;
164
+ }
165
+ // Trigger Default Override W/ Individual Element In Line Class Easing Settings
166
+ if ($this.hasClass('linear')) {
167
+ scrolldEasing = 'linear';
168
+ }
169
+ if ($this.hasClass('linearMobile')) {
170
+ scrolldMobileEasing = 'linear';
171
+ }
172
+ if ($this.hasClass('swing')) {
173
+ scrolldEasing = 'swing';
174
+ }
175
+ if ($this.hasClass('swingMobile')) {
176
+ scrolldMobileEasing = 'swing';
177
+ }
178
+ if ($this.hasClass('jswing')) {
179
+ scrolldEasing = 'jswing';
180
+ }
181
+ if ($this.hasClass('jswingMobile')) {
182
+ scrolldMobileEasing = 'jswing';
183
+ }
184
+ if ($this.hasClass('easeInQuad')) {
185
+ scrolldEasing = 'easeInQuad';
186
+ }
187
+ if ($this.hasClass('easeInQuadMobile')) {
188
+ scrolldMobileEasing = 'easeInQuad';
189
+ }
190
+ if ($this.hasClass('easeOutQuad')) {
191
+ scrolldEasing = 'easeOutQuad';
192
+ }
193
+ if ($this.hasClass('easeOutQuadMobile')) {
194
+ scrolldMobileEasing = 'easeOutQuad';
195
+ }
196
+ if ($this.hasClass('easeInOutQuad')) {
197
+ scrolldEasing = 'easeInOutQuad';
198
+ }
199
+ if ($this.hasClass('easeInOutQuadMobile')) {
200
+ scrolldMobileEasing = 'easeInOutQuad';
201
+ }
202
+ if ($this.hasClass('easeInCubic')) {
203
+ scrolldEasing = 'easeInCubic';
204
+ }
205
+ if ($this.hasClass('easeInCubicMobile')) {
206
+ scrolldMobileEasing = 'easeInCubic';
207
+ }
208
+ if ($this.hasClass('easeOutCubic')) {
209
+ scrolldEasing = 'easeOutCubic';
210
+ }
211
+ if ($this.hasClass('easeOutCubicMobile')) {
212
+ scrolldMobileEasing = 'easeOutCubic';
213
+ }
214
+ if ($this.hasClass('easeInOutCubic')) {
215
+ scrolldEasing = 'easeInOutCubic';
216
+ }
217
+ if ($this.hasClass('easeInOutCubicMobile')) {
218
+ scrolldMobileEasing = 'easeInOutCubic';
219
+ }
220
+ if ($this.hasClass('easeInQuart')) {
221
+ scrolldEasing = 'easeInQuart';
222
+ }
223
+ if ($this.hasClass('easeInQuartMobile')) {
224
+ scrolldMobileEasing = 'easeInQuart';
225
+ }
226
+ if ($this.hasClass('easeOutQuart')) {
227
+ scrolldEasing = 'easeOutQuart';
228
+ }
229
+ if ($this.hasClass('easeOutQuartMobile')) {
230
+ scrolldMobileEasing = 'easeOutQuart';
231
+ }
232
+ if ($this.hasClass('easeInOutQuart')) {
233
+ scrolldEasing = 'easeInOutQuart';
234
+ }
235
+ if ($this.hasClass('easeInOutQuartMobile')) {
236
+ scrolldMobileEasing = 'easeInOutQuart';
237
+ }
238
+ if ($this.hasClass('easeInQuint')) {
239
+ scrolldEasing = 'easeInQuint';
240
+ }
241
+ if ($this.hasClass('easeInQuintMobile')) {
242
+ scrolldMobileEasing = 'easeInQuint';
243
+ }
244
+ if ($this.hasClass('easeOutQuint')) {
245
+ scrolldEasing = 'easeOutQuint';
246
+ }
247
+ if ($this.hasClass('easeOutQuintMobile')) {
248
+ scrolldMobileEasing = 'easeOutQuint';
249
+ }
250
+ if ($this.hasClass('easeInOutQuint')) {
251
+ scrolldEasing = 'easeInOutQuint';
252
+ }
253
+ if ($this.hasClass('easeInOutQuintMobile')) {
254
+ scrolldMobileEasing = 'easeInOutQuint';
255
+ }
256
+ if ($this.hasClass('easeInSine')) {
257
+ scrolldEasing = 'easeInSine';
258
+ }
259
+ if ($this.hasClass('easeInSineMobile')) {
260
+ scrolldMobileEasing = 'easeInSine';
261
+ }
262
+ if ($this.hasClass('easeOutSine')) {
263
+ scrolldEasing = 'easeOutSine';
264
+ }
265
+ if ($this.hasClass('easeOutSineMobile')) {
266
+ scrolldMobileEasing = 'easeOutSine';
267
+ }
268
+ if ($this.hasClass('easeInOutSine')) {
269
+ scrolldEasing = 'easeInOutSine';
270
+ }
271
+ if ($this.hasClass('easeInOutSineMobile')) {
272
+ scrolldMobileEasing = 'easeInOutSine';
273
+ }
274
+ if ($this.hasClass('easeInExpo')) {
275
+ scrolldEasing = 'easeInExpo';
276
+ }
277
+ if ($this.hasClass('easeInExpoMobile')) {
278
+ scrolldMobileEasing = 'easeInExpo';
279
+ }
280
+ if ($this.hasClass('easeOutExpo')) {
281
+ scrolldEasing = 'easeOutExpo';
282
+ }
283
+ if ($this.hasClass('easeOutExpoMobile')) {
284
+ scrolldMobileEasing = 'easeOutExpo';
285
+ }
286
+ if ($this.hasClass('easeInOutExpo')) {
287
+ scrolldEasing = 'easeInOutExpo';
288
+ }
289
+ if ($this.hasClass('easeInOutExpoMobile')) {
290
+ scrolldMobileEasing = 'easeInOutExpo';
291
+ }
292
+ if ($this.hasClass('easeInCirc')) {
293
+ scrolldEasing = 'easeInCirc';
294
+ }
295
+ if ($this.hasClass('easeInCircMobile')) {
296
+ scrolldMobileEasing = 'easeInCirc';
297
+ }
298
+ if ($this.hasClass('easeOutCirc')) {
299
+ scrolldEasing = 'easeOutCirc';
300
+ }
301
+ if ($this.hasClass('easeOutCircMobile')) {
302
+ scrolldMobileEasing = 'easeOutCirc';
303
+ }
304
+ if ($this.hasClass('easeInOutCirc')) {
305
+ scrolldEasing = 'easeInOutCirc';
306
+ }
307
+ if ($this.hasClass('easeInOutCircMobile')) {
308
+ scrolldMobileEasing = 'easeInOutCirc';
309
+ }
310
+ if ($this.hasClass('easeInElastic')) {
311
+ scrolldEasing = 'easeInElastic';
312
+ }
313
+ if ($this.hasClass('easeInElasticMobile')) {
314
+ scrolldMobileEasing = 'easeInElastic';
315
+ }
316
+ if ($this.hasClass('easeOutElastic')) {
317
+ scrolldEasing = 'easeOutElastic';
318
+ }
319
+ if ($this.hasClass('easeOutElasticMobile')) {
320
+ scrolldMobileEasing = 'easeOutElastic';
321
+ }
322
+ if ($this.hasClass('easeInOutElastic')) {
323
+ scrolldEasing = 'easeInOutElastic';
324
+ }
325
+ if ($this.hasClass('easeInOutElasticMobile')) {
326
+ scrolldMobileEasing = 'easeInOutElastic';
327
+ }
328
+ if ($this.hasClass('easeInBack')) {
329
+ scrolldEasing = 'easeInBack';
330
+ }
331
+ if ($this.hasClass('easeInBackMobile')) {
332
+ scrolldMobileEasing = 'easeInBack';
333
+ }
334
+ if ($this.hasClass('easeOutBack')) {
335
+ scrolldEasing = 'easeOutBack';
336
+ }
337
+ if ($this.hasClass('easeOutBackMobile')) {
338
+ scrolldMobileEasing = 'easeOutBack';
339
+ }
340
+ if ($this.hasClass('easeInOutBack')) {
341
+ scrolldEasing = 'easeInOutBack';
342
+ }
343
+ if ($this.hasClass('easeInOutBackMobile')) {
344
+ scrolldMobileEasing = 'easeInOutBack';
345
+ }
346
+ if ($this.hasClass('easeInBounce')) {
347
+ scrolldEasing = 'easeInBounce';
348
+ }
349
+ if ($this.hasClass('easeInBounceMobile')) {
350
+ scrolldMobileEasing = 'easeInBounce';
351
+ }
352
+ if ($this.hasClass('easeOutBounce')) {
353
+ scrolldEasing = 'easeOutBounce';
354
+ }
355
+ if ($this.hasClass('easeOutBounceMobile')) {
356
+ scrolldMobileEasing = 'easeOutBounce';
357
+ }
358
+ if ($this.hasClass('easeInOutBounce')) {
359
+ scrolldEasing = 'easeInOutBounce';
360
+ }
361
+ if ($this.hasClass('easeInOutBounceMobile')) {
362
+ scrolldMobileEasing = 'easeInOutBounce';
363
+ }
364
+ if ($this.hasClass('scrolldEasing1')) {
365
+ scrolldEasing = 'scrolldEasing1';
366
+ }
367
+ if ($this.hasClass('scrolldEasing1Mobile')) {
368
+ scrolldMobileEasing = 'scrolldEasing1';
369
+ }
370
+ if ($this.hasClass('scrolldEasing2')) {
371
+ scrolldEasing = 'scrolldEasing2';
372
+ }
373
+ if ($this.hasClass('scrolldEasing2Mobile')) {
374
+ scrolldMobileEasing = 'scrolldEasing2';
375
+ }
376
+ if ($this.hasClass('scrolldEasing3')) {
377
+ scrolldEasing = 'scrolldEasing3';
378
+ }
379
+ if ($this.hasClass('scrolldEasing3Mobile')) {
380
+ scrolldMobileEasing = 'scrolldEasing3';
381
+ }
382
+ /// Dynamic Scrolling / Set Animation
383
+ // Mobile Only
384
+ if (x < scrolldMobileWidth) {
385
+ if (scrolldMobile === true && scrolldMobileFixed === false) {
386
+ if (h <= idScrollDivElementHeight) {
387
+ htmlBody.stop(true).animate({
388
+ scrollTop: scrolldMobileDistanceMin
389
+ },
390
+ scrolldMobileSpeed,
391
+ scrolldMobileEasing)
392
+ } else {
393
+ htmlBody.stop(true).animate({
394
+ scrollTop: scrolldMobileDistance
395
+ },
396
+ scrolldMobileSpeed,
397
+ scrolldMobileEasing)
398
+ }
399
+ } else if (scrolldMobile === true && scrolldMobileFixed === true) {
400
+ if (h <= (idScrollDivElementHeight + (scrolldMobileFixed * 2)) && scrolldMobileDistanceMin === scrolldTop) {
401
+ htmlBody.stop(true).animate({
402
+ scrollTop: scrolldTopFixed
403
+ },
404
+ scrolldMobileSpeed,
405
+ scrolldMobileEasing)
406
+ } else if (h <= (idScrollDivElementHeight + (scrolldMobileFixed * 2)) && scrolldMobileDistanceMin === scrolldPre) {
407
+ htmlBody.stop(true).animate({
408
+ scrollTop: scrolldPreFixed
409
+ },
410
+ scrolldMobileSpeed,
411
+ scrolldMobileEasing)
412
+ } else if (h <= (idScrollDivElementHeight + (scrolldMobileFixed * 2)) && scrolldMobileDistanceMin === scrolldCenter) {
413
+ htmlBody.stop(true).animate({
414
+ scrollTop: scrolldCenter
415
+ },
416
+ scrolldMobileSpeed,
417
+ scrolldMobileEasing)
418
+ } else if (h > (idScrollDivElementHeight + (scrolldMobileFixed * 2)) && scrolldMobileDistance === scrolldTop) {
419
+ htmlBody.stop(true).animate({
420
+ scrollTop: scrolldTopFixed
421
+ },
422
+ scrolldMobileSpeed,
423
+ scrolldMobileEasing)
424
+ } else if (h > (idScrollDivElementHeight + (scrolldMobileFixed * 2)) && scrolldMobileDistance === scrolldPre) {
425
+ htmlBody.stop(true).animate({
426
+ scrollTop: scrolldPreFixed
427
+ },
428
+ scrolldMobileSpeed,
429
+ scrolldMobileEasing)
430
+ } else if (h > (idScrollDivElementHeight + (scrolldMobileFixed * 2)) && scrolldMobileDistance === scrolldCenter) {
431
+ htmlBody.stop(true).animate({
432
+ scrollTop: scrolldCenter
433
+ },
434
+ scrolldMobileSpeed,
435
+ scrolldMobileEasing)
436
+ } else {
437
+ htmlBody.stop(true).animate({
438
+ scrollTop: scrolldMobileDistance
439
+ },
440
+ scrolldMobileSpeed,
441
+ scrolldMobileEasing)
442
+ }
443
+ } else if (scrolldMobile === false) {
444
+ scrolldMobileWidth = 1;
445
+ }
446
+ }
447
+ // Web Only
448
+ if (x >= scrolldMobileWidth) {
449
+ if (scrolldFixed === false) {
450
+ if (h <= idScrollDivElementHeight) {
451
+ htmlBody.stop(true).animate({
452
+ scrollTop: scrolldDistanceMin
453
+ },
454
+ scrolldSpeed,
455
+ scrolldEasing)
456
+ } else {
457
+ htmlBody.stop(true).animate({
458
+ scrollTop: scrolldDistance
459
+ },
460
+ scrolldMobileSpeed,
461
+ scrolldMobileEasing)
462
+ }
463
+ } else if (scrolldFixed === true) {
464
+ if (h <= (idScrollDivElementHeight + scrolldFixed) && scrolldDistanceMin === scrolldTop) {
465
+ htmlBody.stop(true).animate({
466
+ scrollTop: scrolldTopFixed
467
+ },
468
+ scrolldSpeed,
469
+ scrolldEasing)
470
+ } else if (h <= (idScrollDivElementHeight + scrolldFixed) && scrolldDistanceMin === scrolldPre) {
471
+ htmlBody.stop(true).animate({
472
+ scrollTop: scrolldPreFixed
473
+ },
474
+ scrolldSpeed,
475
+ scrolldEasing)
476
+ } else if (h <= (idScrollDivElementHeight + scrolldFixed * 2) && scrolldDistanceMin === scrolldCenter) {
477
+ htmlBody.stop(true).animate({
478
+ scrollTop: scrolldCenter
479
+ },
480
+ scrolldSpeed,
481
+ scrolldEasing)
482
+ } else if (h > (idScrollDivElementHeight + scrolldFixed) && scrolldDistance === scrolldTop) {
483
+ htmlBody.stop(true).animate({
484
+ scrollTop: scrolldTopFixed
485
+ },
486
+ scrolldSpeed,
487
+ scrolldEasing)
488
+ } else if (h > (idScrollDivElementHeight + scrolldFixed) && scrolldDistance === scrolldPre) {
489
+ htmlBody.stop(true).animate({
490
+ scrollTop: scrolldPreFixed
491
+ },
492
+ scrolldSpeed,
493
+ scrolldEasing)
494
+ } else if (h > (idScrollDivElementHeight + scrolldFixed * 2) && scrolldDistance === scrolldCenter) {
495
+ htmlBody.stop(true).animate({
496
+ scrollTop: scrolldCenter
497
+ },
498
+ scrolldSpeed,
499
+ scrolldEasing)
500
+ } else {
501
+ htmlBody.stop(true).animate({
502
+ scrollTop: scrolldDistance
503
+ },
504
+ scrolldSpeed,
505
+ scrolldEasing)
506
+ }
507
+ }
508
+ }
509
+ }
510
+ });
511
+ return this;
512
+ }
513
+ })(jQuery);
@@ -0,0 +1,31 @@
1
+ (function ($) {
2
+ $.fn.scrolld = function (options) {
3
+ var scrolldCustom = 0;
4
+ var scrolldNavBar = 'fixedNavBar';
5
+ var scrolldMobileNavBar = 'fixedNavBar';
6
+
7
+ var $win=$(window);var doc=document;var y=$win.scrollTop();var h=$win.height();var x=$win.width();var htmlBody=$("html, body");$win.scroll(function(a){y=$win.scrollTop();a.stopImmediatePropagation();return false});$win.resize(function(a){h=$win.height();x=$win.width();a.stopImmediatePropagation();return false});$.easing.scrolldEasing1=function(f,g,e,k,j){var i=(g/=j)*g;var a=i*g;return e+k*(-3.6*a*i+4.3*i*i+0.2*a+0.1*i)};$.easing.scrolldEasing2=function(f,g,e,k,j){var i=(g/=j)*g;var a=i*g;return e+k*(18.9925*a*i+-45.23*i*i+40.28*a+-19.89*i+6.8475*g)};$.easing.scrolldEasing3=function(e,f,a,i,g){if((f/=g)<(1.25/3)){return i*(9.5625*f*f)+a}else{if(f<(2.25/3)){return i*(8.5625*(f-=(1.5/2.75))*f+0.85)+a}else{if(f<(2.75/3)){return i*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return i*(5.5625*(f-=(2.625/2.75))*f+1)+a}}}};var speed1=100;var speed2=200;var speed3=300;var speed4=400;var speed5=500;var speed6=600;var speed7=700;var speed8=800;var speed9=900;var speed10=1000;var speed11=1100;var speed12=1200;var speed13=1300;var speed14=1400;var speed15=1500;var speed16=1600;var speed17=1700;var speed18=1800;var speed19=1900;var speed20=2000;var speedX=3000;var idScroll=$(this).attr("id");var scrolldFixed=$("#"+scrolldNavBar).outerHeight();var scrolldMobileFixed=$("#"+scrolldMobileNavBar).outerHeight();var idScrollElement=$("#"+idScroll);var idScrollString=idScroll.substr(0,idScroll.length-3);var idScrollDiv=document.getElementById(idScrollString).id;var idScrollDivElement=$("#"+idScrollDiv);var offsetDivElementTop=Math.round(idScrollDivElement.offset().top);var idScrollDivElementHeight=Math.round(idScrollDivElement.height());var scrolldTop=offsetDivElementTop+scrolldCustom;var scrolldTopFixed=Math.round(offsetDivElementTop-scrolldFixed)+scrolldCustom;var scrolldPre=offsetDivElementTop-Math.round(h/15)+scrolldCustom;var scrolldPreFixed=offsetDivElementTop-scrolldFixed-Math.round(h/20)+scrolldCustom;var scrolldCenter=offsetDivElementTop-Math.round(h/2-idScrollDivElementHeight/2);var scrolldMobileTopFixed=Math.round(offsetDivElementTop-scrolldMobileFixed)+scrolldCustom;var scrolldMobilePreFixed=offsetDivElementTop-scrolldMobileFixed-Math.round(h/20)+scrolldCustom;var scrolldDistance=scrolldTop;var scrolldDistanceMin=scrolldTop;var scrolldSpeed=speed9;var scrolldEasing="scrolldEasing1";var scrolldFixed=true;var scrolldMobile=true;var scrolldMobileWidth=979;var scrolldMobileDistance=scrolldTop;var scrolldMobileDistanceMin=scrolldTop;var scrolldMobileSpeed=speed9;var scrolldMobileEasing="scrolldEasing1";var scrolldMobileFixed=true;
8
+
9
+
10
+ var
11
+ defaults = {
12
+ scrolldDistance: scrolldPre,
13
+ scrolldDistanceMin: scrolldPre,
14
+ scrolldSpeed: speed11,
15
+ scrolldEasing: 'scrolldEasing1',
16
+ scrolldFixed: 'true',
17
+
18
+ scrolldMobile: 'true',
19
+ scrolldMobileWidth: 979,
20
+ scrolldMobileDistance: scrolldPre,
21
+ scrolldMobileDistanceMin: scrolldPre,
22
+ scrolldMobileSpeed: speed11,
23
+ scrolldMobileEasing: 'scrolldEasing1',
24
+ scrolldMobileFixed: 'true'
25
+ },
26
+
27
+ settings=$.extend({},defaults,options);this.each(function(){if($(this).attr("id")!=""){var a=$(this);if(settings.scrolldDistance){scrolldDistance=settings.scrolldDistance}if(settings.scrolldDistanceMin){scrolldDistanceMin=settings.scrolldDistanceMin}if(settings.scrolldSpeed){scrolldSpeed=settings.scrolldSpeed}if(settings.scrolldEasing){scrolldEasing=settings.scrolldEasing}if(settings.scrolldFixed==="false"){scrolldFixed=false}if(settings.scrolldMobile==="false"){scrolldMobile=false}if(settings.scrolldMobileWidth){scrolldMobileWidth=settings.scrolldMobileWidth}if(settings.scrolldMobileDistance){scrolldMobileDistance=settings.scrolldMobileDistance}if(settings.scrolldMobileDistanceMin){scrolldMobileDistanceMin=settings.scrolldMobileDistanceMin}if(settings.scrolldMobileSpeed){scrolldMobileSpeed=settings.scrolldMobileSpeed}if(settings.scrolldMobileEasing){scrolldMobileEasing=settings.scrolldMobileEasing}if(settings.scrolldMobileFixed==="false"){scrolldMobileFixed=false}if(a.hasClass("linear")){scrolldEasing="linear"}if(a.hasClass("linearMobile")){scrolldMobileEasing="linear"}if(a.hasClass("swing")){scrolldEasing="swing"}if(a.hasClass("swingMobile")){scrolldMobileEasing="swing"}if(a.hasClass("jswing")){scrolldEasing="jswing"}if(a.hasClass("jswingMobile")){scrolldMobileEasing="jswing"}if(a.hasClass("easeInQuad")){scrolldEasing="easeInQuad"}if(a.hasClass("easeInQuadMobile")){scrolldMobileEasing="easeInQuad"}if(a.hasClass("easeOutQuad")){scrolldEasing="easeOutQuad"}if(a.hasClass("easeOutQuadMobile")){scrolldMobileEasing="easeOutQuad"}if(a.hasClass("easeInOutQuad")){scrolldEasing="easeInOutQuad"}if(a.hasClass("easeInOutQuadMobile")){scrolldMobileEasing="easeInOutQuad"}if(a.hasClass("easeInCubic")){scrolldEasing="easeInCubic"}if(a.hasClass("easeInCubicMobile")){scrolldMobileEasing="easeInCubic"}if(a.hasClass("easeOutCubic")){scrolldEasing="easeOutCubic"}if(a.hasClass("easeOutCubicMobile")){scrolldMobileEasing="easeOutCubic"}if(a.hasClass("easeInOutCubic")){scrolldEasing="easeInOutCubic"}if(a.hasClass("easeInOutCubicMobile")){scrolldMobileEasing="easeInOutCubic"}if(a.hasClass("easeInQuart")){scrolldEasing="easeInQuart"}if(a.hasClass("easeInQuartMobile")){scrolldMobileEasing="easeInQuart"}if(a.hasClass("easeOutQuart")){scrolldEasing="easeOutQuart"}if(a.hasClass("easeOutQuartMobile")){scrolldMobileEasing="easeOutQuart"}if(a.hasClass("easeInOutQuart")){scrolldEasing="easeInOutQuart"}if(a.hasClass("easeInOutQuartMobile")){scrolldMobileEasing="easeInOutQuart"}if(a.hasClass("easeInQuint")){scrolldEasing="easeInQuint"}if(a.hasClass("easeInQuintMobile")){scrolldMobileEasing="easeInQuint"}if(a.hasClass("easeOutQuint")){scrolldEasing="easeOutQuint"}if(a.hasClass("easeOutQuintMobile")){scrolldMobileEasing="easeOutQuint"}if(a.hasClass("easeInOutQuint")){scrolldEasing="easeInOutQuint"}if(a.hasClass("easeInOutQuintMobile")){scrolldMobileEasing="easeInOutQuint"}if(a.hasClass("easeInSine")){scrolldEasing="easeInSine"}if(a.hasClass("easeInSineMobile")){scrolldMobileEasing="easeInSine"}if(a.hasClass("easeOutSine")){scrolldEasing="easeOutSine"}if(a.hasClass("easeOutSineMobile")){scrolldMobileEasing="easeOutSine"}if(a.hasClass("easeInOutSine")){scrolldEasing="easeInOutSine"}if(a.hasClass("easeInOutSineMobile")){scrolldMobileEasing="easeInOutSine"}if(a.hasClass("easeInExpo")){scrolldEasing="easeInExpo"}if(a.hasClass("easeInExpoMobile")){scrolldMobileEasing="easeInExpo"}if(a.hasClass("easeOutExpo")){scrolldEasing="easeOutExpo"}if(a.hasClass("easeOutExpoMobile")){scrolldMobileEasing="easeOutExpo"}if(a.hasClass("easeInOutExpo")){scrolldEasing="easeInOutExpo"}if(a.hasClass("easeInOutExpoMobile")){scrolldMobileEasing="easeInOutExpo"}if(a.hasClass("easeInCirc")){scrolldEasing="easeInCirc"}if(a.hasClass("easeInCircMobile")){scrolldMobileEasing="easeInCirc"}if(a.hasClass("easeOutCirc")){scrolldEasing="easeOutCirc"}if(a.hasClass("easeOutCircMobile")){scrolldMobileEasing="easeOutCirc"}if(a.hasClass("easeInOutCirc")){scrolldEasing="easeInOutCirc"}if(a.hasClass("easeInOutCircMobile")){scrolldMobileEasing="easeInOutCirc"}if(a.hasClass("easeInElastic")){scrolldEasing="easeInElastic"}if(a.hasClass("easeInElasticMobile")){scrolldMobileEasing="easeInElastic"}if(a.hasClass("easeOutElastic")){scrolldEasing="easeOutElastic"}if(a.hasClass("easeOutElasticMobile")){scrolldMobileEasing="easeOutElastic"}if(a.hasClass("easeInOutElastic")){scrolldEasing="easeInOutElastic"}if(a.hasClass("easeInOutElasticMobile")){scrolldMobileEasing="easeInOutElastic"}if(a.hasClass("easeInBack")){scrolldEasing="easeInBack"}if(a.hasClass("easeInBackMobile")){scrolldMobileEasing="easeInBack"}if(a.hasClass("easeOutBack")){scrolldEasing="easeOutBack"}if(a.hasClass("easeOutBackMobile")){scrolldMobileEasing="easeOutBack"}if(a.hasClass("easeInOutBack")){scrolldEasing="easeInOutBack"}if(a.hasClass("easeInOutBackMobile")){scrolldMobileEasing="easeInOutBack"}if(a.hasClass("easeInBounce")){scrolldEasing="easeInBounce"}if(a.hasClass("easeInBounceMobile")){scrolldMobileEasing="easeInBounce"}if(a.hasClass("easeOutBounce")){scrolldEasing="easeOutBounce"}if(a.hasClass("easeOutBounceMobile")){scrolldMobileEasing="easeOutBounce"}if(a.hasClass("easeInOutBounce")){scrolldEasing="easeInOutBounce"}if(a.hasClass("easeInOutBounceMobile")){scrolldMobileEasing="easeInOutBounce"}if(a.hasClass("scrolldEasing1")){scrolldEasing="scrolldEasing1"}if(a.hasClass("scrolldEasing1Mobile")){scrolldMobileEasing="scrolldEasing1"}if(a.hasClass("scrolldEasing2")){scrolldEasing="scrolldEasing2"}if(a.hasClass("scrolldEasing2Mobile")){scrolldMobileEasing="scrolldEasing2"}if(a.hasClass("scrolldEasing3")){scrolldEasing="scrolldEasing3"}if(a.hasClass("scrolldEasing3Mobile")){scrolldMobileEasing="scrolldEasing3"}if(x<scrolldMobileWidth){if(scrolldMobile===true&&scrolldMobileFixed===false){if(h<=idScrollDivElementHeight){htmlBody.stop(true).animate({scrollTop:scrolldMobileDistanceMin},scrolldMobileSpeed,scrolldMobileEasing)}else{htmlBody.stop(true).animate({scrollTop:scrolldMobileDistance},scrolldMobileSpeed,scrolldMobileEasing)}}else{if(scrolldMobile===true&&scrolldMobileFixed===true){if(h<=(idScrollDivElementHeight+(scrolldMobileFixed*2))&&scrolldMobileDistanceMin===scrolldTop){htmlBody.stop(true).animate({scrollTop:scrolldTopFixed},scrolldMobileSpeed,scrolldMobileEasing)}else{if(h<=(idScrollDivElementHeight+(scrolldMobileFixed*2))&&scrolldMobileDistanceMin===scrolldPre){htmlBody.stop(true).animate({scrollTop:scrolldPreFixed},scrolldMobileSpeed,scrolldMobileEasing)}else{if(h<=(idScrollDivElementHeight+(scrolldMobileFixed*2))&&scrolldMobileDistanceMin===scrolldCenter){htmlBody.stop(true).animate({scrollTop:scrolldCenter},scrolldMobileSpeed,scrolldMobileEasing)}else{if(h>(idScrollDivElementHeight+(scrolldMobileFixed*2))&&scrolldMobileDistance===scrolldTop){htmlBody.stop(true).animate({scrollTop:scrolldTopFixed},scrolldMobileSpeed,scrolldMobileEasing)}else{if(h>(idScrollDivElementHeight+(scrolldMobileFixed*2))&&scrolldMobileDistance===scrolldPre){htmlBody.stop(true).animate({scrollTop:scrolldPreFixed},scrolldMobileSpeed,scrolldMobileEasing)}else{if(h>(idScrollDivElementHeight+(scrolldMobileFixed*2))&&scrolldMobileDistance===scrolldCenter){htmlBody.stop(true).animate({scrollTop:scrolldCenter},scrolldMobileSpeed,scrolldMobileEasing)}else{htmlBody.stop(true).animate({scrollTop:scrolldMobileDistance},scrolldMobileSpeed,scrolldMobileEasing)}}}}}}}else{if(scrolldMobile===false){scrolldMobileWidth=1}}}}if(x>=scrolldMobileWidth){if(scrolldFixed===false){if(h<=idScrollDivElementHeight){htmlBody.stop(true).animate({scrollTop:scrolldDistanceMin},scrolldSpeed,scrolldEasing)}else{htmlBody.stop(true).animate({scrollTop:scrolldDistance},scrolldMobileSpeed,scrolldMobileEasing)}}else{if(scrolldFixed===true){if(h<=(idScrollDivElementHeight+scrolldFixed)&&scrolldDistanceMin===scrolldTop){htmlBody.stop(true).animate({scrollTop:scrolldTopFixed},scrolldSpeed,scrolldEasing)}else{if(h<=(idScrollDivElementHeight+scrolldFixed)&&scrolldDistanceMin===scrolldPre){htmlBody.stop(true).animate({scrollTop:scrolldPreFixed},scrolldSpeed,scrolldEasing)}else{if(h<=(idScrollDivElementHeight+scrolldFixed*2)&&scrolldDistanceMin===scrolldCenter){htmlBody.stop(true).animate({scrollTop:scrolldCenter},scrolldSpeed,scrolldEasing)}else{if(h>(idScrollDivElementHeight+scrolldFixed)&&scrolldDistance===scrolldTop){htmlBody.stop(true).animate({scrollTop:scrolldTopFixed},scrolldSpeed,scrolldEasing)}else{if(h>(idScrollDivElementHeight+scrolldFixed)&&scrolldDistance===scrolldPre){htmlBody.stop(true).animate({scrollTop:scrolldPreFixed},scrolldSpeed,scrolldEasing)}else{if(h>(idScrollDivElementHeight+scrolldFixed*2)&&scrolldDistance===scrolldCenter){htmlBody.stop(true).animate({scrollTop:scrolldCenter},scrolldSpeed,scrolldEasing)}else{htmlBody.stop(true).animate({scrollTop:scrolldDistance},scrolldSpeed,scrolldEasing)}}}}}}}}}}});
28
+
29
+ return this;
30
+ }
31
+ })(jQuery);
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrolld.js-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Trevor Strieber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jquery-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.17
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.17
55
+ description: Scrolld.js JS for the Rails 3.1+ asset pipeline.
56
+ email:
57
+ - trevor@strieber.org
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - README.md
64
+ - lib/scrolld.js-rails.rb
65
+ - lib/scrolld.js-rails/version.rb
66
+ - vendor/assets/javascripts/scrolld.js
67
+ - vendor/assets/javascripts/scrolld.min.js
68
+ homepage: http://github.com/TrevorS/scrolld.js-rails
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.2.2
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: This gem packages scrolld.js for the Rails 3.1+ asset pipeline.
92
+ test_files: []