Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GoFish doesn't scroll to matching line
Message
From
17/01/2023 16:00:54
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
17/01/2023 15:21:53
General information
Forum:
Visual FoxPro
Category:
VFPX/Sedna
Miscellaneous
Thread ID:
01685788
Message ID:
01685826
Views:
30
>>
>>I do not know your skills (mine are poor), but you can try to single step the JS in FireFox. Just google how to do.
>
>Couldn't manage to step in FireFox, but I was able to do so in Chrome. There's something weird going on here. The JS code that does the scrolling is this:
>
>
>	//Finds y value of given object
>	function findPos(obj) {
>			var curtop = 0;
>			if (obj.offsetParent) {
>				   do {
>						   curtop += obj.offsetTop;
>				   } while (obj = obj.offsetParent);
>			return [curtop];
>			}
>	}
>
>	//Scroll to location of "matchdiv"
>	function ScrollToMatch(){
>		var MatchDiv = document.getElementById('matchline');
>		var matchPosition = findPos(MatchDiv);
>		var bodyHeight = document.body.offsetHeight;
>		var scrollTo = parseInt(matchPosition) - (parseInt(bodyHeight) / 3);
>		window.scroll(0, scrollTo);
>	}
>
>
>When I step through this code on the first sample I created, where there are 198 lines and the match is around line 63, the value for scrollTo comes out negative, which is why is doesn't scroll properly. For the file you sent me, where the match is almost at the end, the calculation gives a value large enough that, if the browser is tall enough, the match shows. Ditto for my second example.
>
>I don't understand why the calculation is the position of the match less 1/3 of the total body height. I get that the idea is to put the match in the middle of the space, but 1/3 of the overall height doesn't seem like it would always give that result.
>
>Tamar

My best guess to the 1/3 problem is, it places the result somewhere below the middle of the visible area, or 1/3 above the lower boundary.
For the negatives, is matchPosition negative or the final result?

Lutz
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform