PageSourceSearch

https://zajec-optika.si/wp-content/themes/enzy/js/jquery.sticky.js?ver=1.3.1

js zajec-optika.si collected 2026-10-08 19:14:22 UTC 4,024 bytes, 129 lines download raw bytes

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