PageSourceSearch

https://www.lennupiletid.ee/et/javascript/_jquery_stickyfloat.js?version=3.2.222

js lennupiletid.ee collected 2026-10-09 21:27:23 UTC 4,535 bytes, 116 lines download raw bytes

1/*
2 * stickyfloat - jQuery plugin for verticaly floating anything in a constrained area
3 * 
4 * Example: jQuery('#menu').stickyfloat({duration: 400});
5 * parameters:
6 * 		duration 	(200)	 - the duration of the animation
7 *		startOffset (number) - the amount of scroll offset after the animations kicks in
8 *		offsetY		(number) - the offset from the top when the object is animated
9 *		lockBottom	(true)	 - set to false if you don't want your floating box to stop at parent's bottom
10 *		delay		(0)		 - delay in milliseconds  until the animnations starts
11		easing		(linear) - easing function (jQuery has by default only 'swing' & 'linear')
12 * $Version: 08.10.2011 r2
13 * $Version: 05.16.2009 r1
14 * Copyright (c) 2009 Yair Even-Or
15 * [email protected]
16 */
17(function(jQ){
18	jQ.fn.stickyfloat = function(options, lockBottom){
19		var jQobj 				= this,
20			doc					= jQ(document),
21			opts, bottomPos, pastStartOffset, objFartherThanTopPos, objBiggerThanWindow, newpos, checkTimer, lastDocPos = doc.scrollTop(),
22			parentPaddingTop 	= parseInt(jQobj.parent().css('padding-top')),
23			startOffset 		= jQobj.parent().offset().top;
24		
25		jQ.extend( jQ.fn.stickyfloat.opts, { startOffset:startOffset, offsetY:parentPaddingTop}, options );
26		opts = jQ.fn.stickyfloat.opts;
27		jQobj.css({ position: 'absolute' });
28		
29		
30		if(opts.lockBottom){
31			bottomPos = jQobj.parent().height() - jQobj.outerHeight() + parentPaddingTop; //get the maximum scrollTop value
32			if( bottomPos < 0 )
33				bottomPos = 0;
34		}
35		
36		function checkScroll(){
37		    if (opts.useHeightHack == true) {
38    		    // hack pro dynamicke (ajaxove) stranky
39    		    bottomPos = jQ(document).height();
40    	    }
41			if( opts.duration > 40 ){
42				clearTimeout(checkTimer);
43				checkTimer = setTimeout(function(){
44					if( Math.abs(doc.scrollTop() - lastDocPos) > 0 ){
45						lastDocPos = doc.scrollTop();
46						initFloat();
47					}
48				},40);
49			}
50			else initFloat();
51		}
52		
53		function initFloat(){
54			jQobj.stop(); // stop all calculations on scroll event
55			startOffset = jQobj.parent().offset().top;
56			pastStartOffset			= doc.scrollTop() > startOffset;	// check if the window was scrolled down more than the start offset declared.
57			objFartherThanTopPos	= jQobj.offset().top > startOffset;	// check if the object is at it's top position (starting point)
58			objBiggerThanWindow 	= jQobj.outerHeight() < jQ(window).height();	// if the window size is smaller than the Obj size, then do not animate.
59			
60			// if window scrolled down more than startOffset OR obj position is greater than
61			// the top position possible (+ offsetY) AND window size must be bigger than Obj size
62			if( (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow){
63				newpos = (doc.scrollTop() -startOffset + opts.offsetY );
64
65				if ( newpos > bottomPos )
66					newpos = bottomPos;
67				if ( doc.scrollTop() < (opts.startOffset+ + opts.appendOffsetY) ) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
68					newpos = parentPaddingTop + opts.appendOffsetY;
69				
70				
71				if (typeof opts.checkColumnBottom != "undefined") {
72					// Pokud je spodek posouvaneho elementu nize, nez spodek hlavniho bloku, zarovname ho podle spodku na stejnou uroven
73					if (opts.checkColumnBottom.length > 0) {
74						objBottomIsLowerThanWrapperBottom = (jQobj.outerHeight() + jQobj.position().top > jQ(opts.checkColumnBottom).outerHeight()) || (newpos + jQobj.outerHeight() > jQ(opts.checkColumnBottom).outerHeight());
75						if (objBottomIsLowerThanWrapperBottom) {
76							newpos = jQ(opts.checkColumnBottom).outerHeight() - jQobj.outerHeight();
77						}
78					}
79					
80					// posouvany element nesmi mit hodnotu top: zapornou
81					if (newpos < 0) {
82						newpos = 0;
83					}
84
85				}
86								
87				jQobj.delay(opts.delay).animate({ top: newpos }, opts.duration , opts.easing );
88			}
89			
90				
91		}
92		
93		jQ(window).scroll(checkScroll);
94		// a zaroven nastavime obalovemu elementu vysku podle vetsiho z obou sloupcu
95		if(jQobj.outerHeight() > jQobj.parent().outerHeight()) {
96			jQobj.parent().css("height", jQobj.outerHeight());
97		}
98	};
99	
100	jQ.fn.stickyfloat.opts = { duration:200, appendOffsetY:0, lockBottom:true , delay:0, easing:'linear' };
101})(jQ);
102
103
104(function(jQ){
105    jQ.fn.delay =  function( time, type ) {
106        time = jQ.fx ? jQ.fx.speeds[time] || time : time;
107        type = type || "fx";
108 
109        return this.queue( type, function() {
110            var elem = this;
111            setTimeout(function() {
112                jQ(elem).dequeue(type);
113            }, time );
114        });
115    }
116})(jQ);

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.