-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F# tooltips position is off #71
Comments
Having the same issue for a while now too , having this issue with chrome |
This is an issue for me in Firefox but seems to work ok in Chrome. |
If someone can do a pull request that would be awesome |
I plan to look into this when I have time, sometime in the next couple of weeks. If someone else beats me to it, though, it looks like |
I've looked at this a little, and the current code is doing exactly what I haven't yet found the details of the interaction, so I don't yet have a solution to propose. |
The reason So why does that matter? Well, it appears that Both of these are normally what you would want, but here they're working against what we're trying to do. I found a detailed discussion of this phenomenon here: This is a discussion between several CodeMirror devs who are trying to figure out how to use CodeMirror inside a CSS-transformed element. (CodeMirror does a lot of positioning various elements relative to each other.) The fifth comment in that discussion looks particularly useful: Nathan Hammond discusses using a "canary" element (as in "canary in the coal mine") to calculate what the transform matrix must be, by setting its position attributes to various values and observing what results. His idea appears to be that they could then apply that transform matrix (or its inverse) to switch between what I'll call "original" coordinates and "transformed" coordinates. In that discussion thread, they eventually give up on that idea because the performance hit of constantly recalculating the positions of elements from a transform matrix would be too great. However, in the FsReveal context, we can afford to take a greater performance hit since we don't need to feel instantly responsive to keystrokes -- and tooltip-position calculations only happen when the user mouses over the code anyway, which isn't very often. So we could potentially rewrite the If you're reading this and that made no sense at all to you, don't worry about it -- I'm mostly writing this down as notes to myself so that I can remember what I was thinking when I come back to this later. (I'm running out of spare time to work on it today). But if you're reading this and this comment made perfect sense to you, then you probably understand CSS and 3D transforms better than I do (I'm a complete novice at 3D math), so _please_ feel free to tackle the problem yourself -- because your solution will probably be better than what I come up with. |
Actually, I believe I've found an answer that should work for every zoom level and screen size -- though it needs testing. Replace your var currentTip = null;
var currentTipElement = null;
function hideTip(evt, name, unique) {
var el = document.getElementById(name);
el.style.display = "none";
currentTip = null;
}
function hideUsingEsc(e) {
if (!e) { e = event; }
hideTip(e, currentTipElement, currentTip);
}
function showTip(evt, name, unique, owner) {
document.onkeydown = hideUsingEsc;
if (currentTip == unique) return;
currentTip = unique;
currentTipElement = name;
var target = owner ? owner : (evt.srcElement ? evt.srcElement : evt.target);
var posx = target.offsetLeft;
var posy = target.offsetTop + target.offsetHeight;
var el = document.getElementById(name);
var parent = target.offsetParent;
el.style.position = "absolute";
el.style.left = posx + "px";
el.style.top = posy + "px";
parent.appendChild(el);
el.style.display = "block";
} Notice how Result: so far I've seen the tooltip show up precisely under its corresponding span, each time, every time. HOWEVER: I still need to test one scenario. Looking at the CSS for I will test this further, and then submit a proper PR. In the meantime, anyone affected by this bug has a workaround: after you run If that's too much hassle for you, then just wait for the pull request. Once I fix this properly, it should Just Work™ without needing to edit files that |
The reveal.js animated slide transitions are done with 3D transforms, which throws off the element-positioning logic from FSharp.Formatting since it assumes a "normal" Web page. Under reveal.js, tooltips should be positioned as a sibling of the element they belong with. Then their positioning will be correct no matter what 3D transform is in effect. Fixes fsprojects#71.
I've tested this, and it works properly with NO transitions as well. So here's my PR. |
This should be fixed now that FsReveal 1.3.1 is out. If @vlaci can confirm that it works, this issue can be closed. You can tell if you have FsReveal 1.3.1 by looking at your |
I've also had this issue for a while and updating to 1.3.1 fixed it, I think this issue can be closed. |
On my notebook at 1366x768 resolution tooltips of all example presentation are displayed at the bootom edge of the screen and sometimes even off the screen. The problem is present in both IE11 and FF38 at normal zoom level.
I fixed the issue for mysef by replacing the following call of getPos:
To:
I don't know how the findPos code should be better than just getting the coordinates directly from the event args.
The text was updated successfully, but these errors were encountered: