Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GoFish doesn't scroll to matching line
Message
From
17/01/2023 15:21:53
 
 
To
13/01/2023 15:45:52
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
VFPX/Sedna
Miscellaneous
Thread ID:
01685788
Message ID:
01685825
Views:
37
>
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform