PageSourceSearch

https://apprendreencoeur.org/wp-content/themes/reactif-bootstrap/library/js/jquery.sticky.js?ver=1.2

js apprendreencoeur.org collected 2026-10-04 13:42:50 UTC 4,866 bytes, 144 lines download raw bytes

1// Sticky Plugin v1.0.0 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: 2/14/2011
7// Date: 2/12/2012
8// Website: http://labs.anthonygarand.com/sticky
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.
12
13(function($) {
14  var defaults = {
15      topSpacing: 0,
16      bottomSpacing: 0,
17      className: 'is-sticky',
18      wrapperClassName: 'sticky-wrapper',
19      center: false,
20      getWidthFrom: ''
21    },
22    $window = $(window),
23    $document = $(document),
24    sticked = [],
25    windowHeight = $window.height(),
26    scroller = function() {
27      var scrollTop = $window.scrollTop(),
28        documentHeight = $document.height(),
29        dwh = documentHeight - windowHeight,
30        extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
31
32      for (var i = 0; i < sticked.length; i++) {
33        var s = sticked[i],
34          elementTop = s.stickyWrapper.offset().top,
35          etse = elementTop - s.topSpacing - extra;
36
37        if (scrollTop <= etse) {
38          if (s.currentTop !== null) {
39            s.stickyElement
40              .css('position', '')
41              .css('top', '');
42			  
43/*Gokul*/
44			if( (s.stickyElement.parent().hasClass(s.className) )){
45				s.stickyElement.parent().animate({},{queue:false, duration:250, easing: 'linear',complete: function(){ s.stickyElement.parent().removeClass(s.className); }});
46			} 
47/*Gokul End*/
48
49            s.currentTop = null;
50          }
51        }
52        else {
53          var newTop = documentHeight - s.stickyElement.outerHeight()
54            - s.topSpacing - s.bottomSpacing - scrollTop - extra;
55          if (newTop < 0) {
56            newTop = newTop + s.topSpacing;
57          } else {
58            newTop = s.topSpacing;
59          }
60          if (s.currentTop != newTop) {
61            s.stickyElement
62              .css('position', 'fixed')
63              .css('top', newTop);
64
65            if (typeof s.getWidthFrom !== 'undefined') {
66              s.stickyElement.css('width', $(s.getWidthFrom).width());
67            }
68
69            //s.stickyElement.parent().addClass(s.className);
70/* Gokul */			
71			if( !(s.stickyElement.parent().hasClass(s.className) )){
72				s.stickyElement.parent().animate({},{queue:false, duration:250, easing: 'linear',complete: function(){ s.stickyElement.parent().addClass(s.className); }});
73			} 
74/*Gokul End*/			
75			
76            s.currentTop = newTop;
77          }
78        }
79      }
80    },
81    resizer = function() {
82      windowHeight = $window.height();
83    },
84    methods = {
85      init: function(options) {
86        var o = $.extend(defaults, options);
87        return this.each(function() {
88          var stickyElement = $(this);
89
90          var stickyId = stickyElement.attr('id');
91          var wrapper = $('<div></div>')
92            .attr('id', stickyId + '-sticky-wrapper')
93            .addClass(o.wrapperClassName);
94          stickyElement.wrapAll(wrapper);
95
96          if (o.center) {
97            stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
98          }
99
100          if (stickyElement.css("float") == "right") {
101            stickyElement.css({"float":"none"}).parent().css({"float":"right"});
102          }
103
104          var stickyWrapper = stickyElement.parent();
105		  
106          stickyWrapper.css('height', stickyElement.outerHeight());
107		  
108		  
109          sticked.push({
110            topSpacing: o.topSpacing,
111            bottomSpacing: o.bottomSpacing,
112            stickyElement: stickyElement,
113            currentTop: null,
114            stickyWrapper: stickyWrapper,
115            className: o.className,
116            getWidthFrom: o.getWidthFrom
117          });
118        });
119      },
120      update: scroller
121    };
122
123  // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
124  if (window.addEventListener) {
125    window.addEventListener('scroll', scroller, false);
126    window.addEventListener('resize', resizer, false);
127  } else if (window.attachEvent) {
128    window.attachEvent('onscroll', scroller);
129    window.attachEvent('onresize', resizer);
130  }
131
132  $.fn.sticky = function(method) {
133    if (methods[method]) {
134      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
135    } else if (typeof method === 'object' || !method ) {
136      return methods.init.apply( this, arguments );
137    } else {
138      $.error('Method ' + method + ' does not exist on jQuery.sticky');
139    }
140  };
141  $(function() {
142    setTimeout(scroller, 0);
143  });
144})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.