jquery-sticky-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0511cb63db22359defb94f7df75f2621e3f66dcc
4
- data.tar.gz: f9aea256a7cdcf201cbf00ac7e8b99b78a4dcc8f
3
+ metadata.gz: 34c4eff3a8d8be2301e7b00c50caafb7af55f705
4
+ data.tar.gz: 125aec83e1af43753772670d0829e17e946c5811
5
5
  SHA512:
6
- metadata.gz: 6556ce0d774f95c4aa46cd4247f77f770b6954907a4ea595083a2f7d9829f0da2fffa4951eee6cefd98678ed93b71a34cf91a8a20d6c8197b680f87270e5a548
7
- data.tar.gz: cc0ad8b38c3dfd575a16763db0e30e18d084257beeed4d1b3906b3be3dc9ee6f34392657093202fd3e24586f92c2f3138d90a5fe65c3bf3167f9440d3dc18e99
6
+ metadata.gz: 326f458e94681077358a30940330e75723f9b93f39a70f77ecc1305fe4b0fd3fbd523377830f7a242c4cc8c5d0721ee317374eaa9fc6fc9826bccdaea0fcdefc
7
+ data.tar.gz: 75e1c258e040fe62e153a42d4c545ae0d8f93b78f34f9205d61c494b821c12e28d82bbf78bc12fb55efffa03e189af95b41b9ddb865ebbfc1cbf90d5568a09d4
@@ -1,6 +1,6 @@
1
1
  module JqueryStickyRails
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- PATCH = 2
4
+ PATCH = 3
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
  end
@@ -1,268 +1,98 @@
1
- // Sticky Plugin v1.0.3 for jQuery
2
- // =============
3
- // Author: Anthony Garand
4
- // Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
5
- // Improvements by Leonardo C. Daronco (daronco)
6
- // Created: 02/14/2011
7
- // Date: 07/20/2015
8
- // Website: http://stickyjs.com/
9
- // Description: Makes an element on the page stick on the screen as you scroll
10
- // It will only set the 'top' and 'position' of your element, you
11
- // might need to adjust the width in some cases.
1
+ var big_image;
2
+ $().ready(function() {
3
+ $('.selector').click(function() {
4
+ SelectColor(this);
5
+ });
6
+ var selectCol = 0;
7
+ if (selectCol == 0) {
8
+ if ($('body').hasClass('landing-page1')) {
12
9
 
13
- (function (factory) {
14
- if (typeof define === 'function' && define.amd) {
15
- // AMD. Register as an anonymous module.
16
- define(['jquery'], factory);
17
- } else if (typeof module === 'object' && module.exports) {
18
- // Node/CommonJS
19
- module.exports = factory(require('jquery'));
20
- } else {
21
- // Browser globals
22
- factory(jQuery);
23
10
  }
24
- }(function ($) {
25
- var slice = Array.prototype.slice; // save ref to original slice()
26
- var splice = Array.prototype.splice; // save ref to original slice()
27
-
28
- var defaults = {
29
- topSpacing: 0,
30
- bottomSpacing: 0,
31
- className: 'is-sticky',
32
- wrapperClassName: 'sticky-wrapper',
33
- center: false,
34
- getWidthFrom: '',
35
- widthFromWrapper: true, // works only when .getWidthFrom is empty
36
- responsiveWidth: false
37
- },
38
- $window = $(window),
39
- $document = $(document),
40
- sticked = [],
41
- windowHeight = $window.height(),
42
- scroller = function() {
43
- var scrollTop = $window.scrollTop(),
44
- documentHeight = $document.height(),
45
- dwh = documentHeight - windowHeight,
46
- extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
47
-
48
- for (var i = 0, l = sticked.length; i < l; i++) {
49
- var s = sticked[i],
50
- elementTop = s.stickyWrapper.offset().top,
51
- etse = elementTop - s.topSpacing - extra;
52
-
53
- //update height in case of dynamic content
54
- s.stickyWrapper.css('height', s.stickyElement.outerHeight());
55
-
56
- if (scrollTop <= etse) {
57
- if (s.currentTop !== null) {
58
- s.stickyElement
59
- .css({
60
- 'width': '',
61
- 'position': '',
62
- 'top': ''
63
- });
64
- s.stickyElement.parent().removeClass(s.className);
65
- s.stickyElement.trigger('sticky-end', [s]);
66
- s.currentTop = null;
67
- }
68
- }
69
- else {
70
- var newTop = documentHeight - s.stickyElement.outerHeight()
71
- - s.topSpacing - s.bottomSpacing - scrollTop - extra;
72
- if (newTop < 0) {
73
- newTop = newTop + s.topSpacing;
74
- } else {
75
- newTop = s.topSpacing;
76
- }
77
- if (s.currentTop !== newTop) {
78
- var newWidth;
79
- if (s.getWidthFrom) {
80
- newWidth = $(s.getWidthFrom).width() || null;
81
- } else if (s.widthFromWrapper) {
82
- newWidth = s.stickyWrapper.width();
83
- }
84
- if (newWidth == null) {
85
- newWidth = s.stickyElement.width();
86
- }
87
- s.stickyElement
88
- .css('width', newWidth)
89
- .css('position', 'fixed')
90
- .css('top', newTop);
91
-
92
- s.stickyElement.parent().addClass(s.className);
93
-
94
- if (s.currentTop === null) {
95
- s.stickyElement.trigger('sticky-start', [s]);
96
- } else {
97
- // sticky is started but it have to be repositioned
98
- s.stickyElement.trigger('sticky-update', [s]);
99
- }
100
-
101
- if (s.currentTop === s.topSpacing && s.currentTop > newTop || s.currentTop === null && newTop < s.topSpacing) {
102
- // just reached bottom || just started to stick but bottom is already reached
103
- s.stickyElement.trigger('sticky-bottom-reached', [s]);
104
- } else if(s.currentTop !== null && newTop === s.topSpacing && s.currentTop < newTop) {
105
- // sticky is started && sticked at topSpacing && overflowing from top just finished
106
- s.stickyElement.trigger('sticky-bottom-unreached', [s]);
107
- }
108
-
109
- s.currentTop = newTop;
110
- }
111
-
112
- // Check if sticky has reached end of container and stop sticking
113
- var stickyWrapperContainer = s.stickyWrapper.parent();
114
- var unstick = (s.stickyElement.offset().top + s.stickyElement.outerHeight() >= stickyWrapperContainer.offset().top + stickyWrapperContainer.outerHeight()) && (s.stickyElement.offset().top <= s.topSpacing);
115
-
116
- if( unstick ) {
117
- s.stickyElement
118
- .css('position', 'absolute')
119
- .css('top', '')
120
- .css('bottom', 0);
121
- } else {
122
- s.stickyElement
123
- .css('position', 'fixed')
124
- .css('top', newTop)
125
- .css('bottom', '');
126
- }
127
- }
128
- }
129
- },
130
- resizer = function() {
131
- windowHeight = $window.height();
11
+ }
132
12
 
133
- for (var i = 0, l = sticked.length; i < l; i++) {
134
- var s = sticked[i];
135
- var newWidth = null;
136
- if (s.getWidthFrom) {
137
- if (s.responsiveWidth) {
138
- newWidth = $(s.getWidthFrom).width();
139
- }
140
- } else if(s.widthFromWrapper) {
141
- newWidth = s.stickyWrapper.width();
142
- }
143
- if (newWidth != null) {
144
- s.stickyElement.css('width', newWidth);
145
- }
146
- }
147
- },
148
- methods = {
149
- init: function(options) {
150
- var o = $.extend({}, defaults, options);
151
- return this.each(function() {
152
- var stickyElement = $(this);
13
+ });
153
14
 
154
- var stickyId = stickyElement.attr('id');
155
- var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName;
156
- var wrapper = $('<div></div>')
157
- .attr('id', wrapperId)
158
- .addClass(o.wrapperClassName);
15
+ $(window).on('scroll', function() {
16
+ responsive = $(window).width();
17
+ if (responsive >= 768) {
18
+ parallax();
19
+ }
20
+ });
159
21
 
160
- stickyElement.wrapAll(wrapper);
22
+ function SelectColor(btn) {
23
+ oldColor = $('.filter-gradient').attr('data-color');
24
+ newColor = $(btn).attr('data-color');
161
25
 
162
- var stickyWrapper = stickyElement.parent();
26
+ oldButton = $('a[id^="Demo"]').attr('data-button');
27
+ newButton = $(btn).attr('data-button');
163
28
 
164
- if (o.center) {
165
- stickyWrapper.css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
166
- }
29
+ $('.filter-gradient').removeClass(oldColor).addClass(newColor).attr('data-color', newColor);
167
30
 
168
- if (stickyElement.css("float") === "right") {
169
- stickyElement.css({"float":"none"}).parent().css({"float":"right"});
170
- }
31
+ $('a[id^="Demo"]').removeClass("btn-" + oldButton).addClass("btn-" + newButton).attr('data-button', newButton);
171
32
 
172
- o.stickyElement = stickyElement;
173
- o.stickyWrapper = stickyWrapper;
174
- o.currentTop = null;
33
+ $('.carousel-indicators').removeClass("carousel-indicators-" + oldColor).addClass("carousel-indicators-" + newColor);
175
34
 
176
- sticked.push(o);
35
+ $('.card').removeClass("card-" + oldColor).addClass("card-" + newColor);
177
36
 
178
- methods.setWrapperHeight(this);
179
- methods.setupChangeListeners(this);
180
- });
181
- },
37
+ $('.selector').removeClass('active');
38
+ $(btn).addClass('active');
39
+ }
182
40
 
183
- setWrapperHeight: function(stickyElement) {
184
- var element = $(stickyElement);
185
- var stickyWrapper = element.parent();
186
- if (stickyWrapper) {
187
- stickyWrapper.css('height', element.outerHeight());
188
- }
189
- },
41
+ $('.switch').each(function() {
42
+ var selector = $(this).parent('li')
43
+ $(this).click(function() {
44
+ if (selector.siblings().hasClass('active')) {
45
+ selector.addClass('active');
46
+ selector.siblings().removeClass('active');
47
+ var slide = $(this).attr('data-slide')
48
+ var lastClass = $('body').attr('class').split(' ').pop();
49
+ $('body').removeClass(lastClass);
50
+ $('body').addClass('landing-page' + slide);
51
+ }
52
+ });
53
+ });
54
+
55
+ var parallax = debounce(function() {
56
+ no_of_elements = 0;
57
+ $('.parallax').each(function() {
58
+ var $elem = $(this);
59
+
60
+ if (isElementInViewport($elem)) {
61
+ var parent_top = $elem.offset().top;
62
+ var window_bottom = $(window).scrollTop();
63
+ var $image = $elem.find('.parallax-background-image')
64
+ var $oVal = ((window_bottom - parent_top) / 3);
65
+ $image.css('margin-top', $oVal + 'px');
66
+ }
67
+ });
68
+ }, 6)
69
+
70
+ function debounce(func, wait, immediate) {
71
+ var timeout;
72
+ return function() {
73
+ var context = this,
74
+ args = arguments;
75
+ clearTimeout(timeout);
76
+ timeout = setTimeout(function() {
77
+ timeout = null;
78
+ if (!immediate) func.apply(context, args);
79
+ }, wait);
80
+ if (immediate && !timeout) func.apply(context, args);
81
+ };
82
+ };
190
83
 
191
- setupChangeListeners: function(stickyElement) {
192
- if (window.MutationObserver) {
193
- var mutationObserver = new window.MutationObserver(function(mutations) {
194
- if (mutations[0].addedNodes.length || mutations[0].removedNodes.length) {
195
- methods.setWrapperHeight(stickyElement);
196
- }
197
- });
198
- mutationObserver.observe(stickyElement, {subtree: true, childList: true});
199
- } else {
200
- stickyElement.addEventListener('DOMNodeInserted', function() {
201
- methods.setWrapperHeight(stickyElement);
202
- }, false);
203
- stickyElement.addEventListener('DOMNodeRemoved', function() {
204
- methods.setWrapperHeight(stickyElement);
205
- }, false);
206
- }
207
- },
208
- update: scroller,
209
- unstick: function(options) {
210
- return this.each(function() {
211
- var that = this;
212
- var unstickyElement = $(that);
213
84
 
214
- var removeIdx = -1;
215
- var i = sticked.length;
216
- while (i-- > 0) {
217
- if (sticked[i].stickyElement.get(0) === that) {
218
- splice.call(sticked,i,1);
219
- removeIdx = i;
220
- }
221
- }
222
- if(removeIdx !== -1) {
223
- unstickyElement.unwrap();
224
- unstickyElement
225
- .css({
226
- 'width': '',
227
- 'position': '',
228
- 'top': '',
229
- 'float': ''
230
- })
231
- ;
232
- }
233
- });
234
- }
235
- };
85
+ function isElementInViewport(elem) {
86
+ var $elem = $(elem);
236
87
 
237
- // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
238
- if (window.addEventListener) {
239
- window.addEventListener('scroll', scroller, false);
240
- window.addEventListener('resize', resizer, false);
241
- } else if (window.attachEvent) {
242
- window.attachEvent('onscroll', scroller);
243
- window.attachEvent('onresize', resizer);
244
- }
88
+ // Get the scroll position of the page.
89
+ var scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1) ? 'body' : 'html');
90
+ var viewportTop = $(scrollElem).scrollTop();
91
+ var viewportBottom = viewportTop + $(window).height();
245
92
 
246
- $.fn.sticky = function(method) {
247
- if (methods[method]) {
248
- return methods[method].apply(this, slice.call(arguments, 1));
249
- } else if (typeof method === 'object' || !method ) {
250
- return methods.init.apply( this, arguments );
251
- } else {
252
- $.error('Method ' + method + ' does not exist on jQuery.sticky');
253
- }
254
- };
93
+ // Get the position of the element on the page.
94
+ var elemTop = Math.round($elem.offset().top);
95
+ var elemBottom = elemTop + $elem.height();
255
96
 
256
- $.fn.unstick = function(method) {
257
- if (methods[method]) {
258
- return methods[method].apply(this, slice.call(arguments, 1));
259
- } else if (typeof method === 'object' || !method ) {
260
- return methods.unstick.apply( this, arguments );
261
- } else {
262
- $.error('Method ' + method + ' does not exist on jQuery.sticky');
263
- }
264
- };
265
- $(function() {
266
- setTimeout(scroller, 0);
267
- });
268
- }));
97
+ return ((elemTop < viewportBottom) && (elemBottom > viewportTop));
98
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-sticky-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilton Garcia