PageSourceSearch

https://aurelienbaro.fr/overlib400/overlib_followscroll.js

js aurelienbaro.fr collected 2026-10-04 03:47:53 UTC 5,089 bytes, 174 lines download raw bytes

1//\/////
2//\  overLIB Follow Scroll Plugin
3//\  This file requires overLIB 4.21 or later.
4//\
5//\  overLIB 4.21 - You may not remove or change this notice.
6//\  Copyright Erik Bosrup 1998-2004. All rights reserved.
7//\  Contributors are listed on the homepage.
8//\  See http://www.bosrup.com/web/overlib/ for details.
9//   $Revision: 1.12 $                      $Date: 2004/11/25 21:27:19 $
10//\/////
11//\mini
12
13////////
14// PRE-INIT
15// Ignore these lines, configuration is below.
16////////
17{
18registerCommands('followscroll,followscrollrefresh');
19
20
21////////
22// DEFAULT CONFIGURATION
23// You don't have to change anything here if you don't want to. All of this can be
24// changed on your html page or through an overLIB call.
25////////
26// Default value for scroll is not to scroll (0)
27if (typeof ol_followscroll=='undefined') var ol_followscroll=0;
28if (typeof ol_followscrollrefresh=='undefined') var ol_followscrollrefresh=100;
29
30////////
31// END OF CONFIGURATION
32// Don't change anything below this line, all configuration is above.
33////////
34
35
36
37
38
39
40
41////////
42// INIT
43////////
44// Runtime variables init. Don't change for config!
45var o3_followscroll=0;
46var o3_followscrollrefresh=100;
47
48
49////////
50// PLUGIN FUNCTIONS
51////////
52function setScrollVariables() {
53	o3_followscroll=ol_followscroll;
54	o3_followscrollrefresh=ol_followscrollrefresh;
55}
56
57// Parses Shadow and Scroll commands
58function parseScrollExtras(pf,i,ar) {
59	var k=i,v;
60	if (k < ar.length) {
61		if (ar[k]==FOLLOWSCROLL) { eval(pf +'followscroll=('+pf+'followscroll==0) ? 1 : 0'); return k; }
62		if (ar[k]==FOLLOWSCROLLREFRESH) { eval(pf+'followscrollrefresh='+ar[++k]); return k; }
63	}
64	return -1;
65}
66
67
68
69// Function to support scroll feature (overloads default)
70function scroll_placeLayer() {
71	var placeX, placeY, widthFix = 0;
72	
73	// HORIZONTAL PLACEMENT
74	if (o3_frame.innerWidth) { 
75		widthFix=Math.ceil(1.2*(o3_frame.outerWidth - o3_frame.innerWidth));
76    widthFix = (widthFix > 50) ? 20 : widthFix;
77		iwidth=o3_frame.innerWidth;
78	} else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientWidth=='number'")&&eval('o3_frame.'+docRoot+'.clientWidth')) 
79		iwidth=eval('o3_frame.'+docRoot+'.clientWidth');			
80
81	// Horizontal scroll offset
82	winoffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollLeft') : o3_frame.pageXOffset;
83
84	placeX = runHook('horizontalPlacement',FCHAIN,iwidth,winoffset,widthFix);
85	
86	// VERTICAL PLACEMENT
87	if (o3_frame.innerHeight) iheight=o3_frame.innerHeight;
88	else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientHeight=='number'")&&eval('o3_frame.'+docRoot+'.clientHeight')) 
89		iheight=eval('o3_frame.'+docRoot+'.clientHeight');			
90
91	// Vertical scroll offset
92	scrolloffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollTop') : o3_frame.pageYOffset;
93
94	placeY = runHook('verticalPlacement',FCHAIN,iheight,scrolloffset);
95
96	// Actually move the object.
97	repositionTo(over,placeX,placeY);
98	
99	if (o3_followscroll && o3_sticky && (o3_relx || o3_rely) && (typeof o3_draggable == 'undefined' || !o3_draggable)) {
100		if (typeof over.scroller=='undefined' || over.scroller.canScroll) over.scroller = new Scroller(placeX-winoffset,placeY-scrolloffset,o3_followscrollrefresh);
101	}
102}
103
104
105
106///////
107// SUPPORT ROUTINES FOR SCROLL FEATURE
108///////
109
110// Scroller constructor
111function Scroller(X,Y,refresh) {
112	this.canScroll=0;
113	this.refresh=refresh;
114	this.x=X;
115	this.y=Y;
116	this.timer=setTimeout("repositionOver()",this.refresh);
117}
118
119// Removes the timer to stop replacing the layer.
120function cancelScroll() {
121	if (!o3_followscroll || typeof over.scroller == 'undefined') return;
122	over.scroller.canScroll = 1;
123	
124	if (over.scroller.timer) {
125		clearTimeout(over.scroller.timer);
126		over.scroller.timer=null;
127	}
128}
129
130// Find out how much we've scrolled.
131	function getPageScrollY() {
132	if (o3_frame.pageYOffset) return o3_frame.pageYOffset;
133	if (eval(docRoot)) return eval('o3_frame.' + docRoot + '.scrollTop');
134	return -1;
135}
136function getPageScrollX() {
137	if (o3_frame.pageXOffset) return o3_frame.pageXOffset;
138	if (eval(docRoot)) return eval('o3_frame.'+docRoot+'.scrollLeft');
139	return -1;
140}
141
142// Find out where our layer is
143function getLayerTop(layer) {
144	if (layer.pageY) return layer.pageY;
145	if (layer.style.top) return parseInt(layer.style.top);
146	return -1;
147}
148function getLayerLeft(layer) {
149	if (layer.pageX) return layer.pageX;
150	if (layer.style.left) return parseInt(layer.style.left);
151	return -1;
152}
153
154// Repositions the layer if needed
155function repositionOver() {
156	var X, Y, pgLeft, pgTop;
157	pgTop = getPageScrollY();
158	pgLeft = getPageScrollX();
159	X = getLayerLeft(over)-pgLeft;
160	Y = getLayerTop(over)-pgTop;
161	
162	if (X != over.scroller.x || Y != over.scroller.y) repositionTo(over, pgLeft+over.scroller.x, pgTop+over.scroller.y);
163	over.scroller.timer = setTimeout("repositionOver()", over.scroller.refresh);
164}
165
166////////
167// PLUGIN REGISTRATIONS
168////////
169registerRunTimeFunction(setScrollVariables);
170registerCmdLineFunction(parseScrollExtras);
171registerHook("hideObject",cancelScroll,FAFTER);
172registerHook("placeLayer",scroll_placeLayer,FREPLACE);
173if (olInfo.meets(4.21)) registerNoParameterCommands('followscroll');
174}

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.