Open rezziemaven opened 4 years ago
Hey @mdolr! Just addressing your two comments:
I thought it would be good to enforce a min-height because when I use an initial height value and then in some cases when the content has a height that's actually less than that, it changes the positioning of the popup above/ below the mouse when the mouse moves again, which to me from a user perspective doesn't seem like expected behaviour. But otherwise if the height of the content is actually larger than the min-height it will extend the height of the popup but up to half the height of the entire screen (which I thought would be a good way to ensure that the popup stays within the visible portion of the screen). However, if you'd still like me to remove the fixed height then I'll update it.
I agree that this isn't expected behaviour. Would you prefer that it at least shows a blank popup which is then filled with content when it's successfully loaded? I was thinking it could perhaps show some indication that the content was loading in a similar way to how the iPhone previews content in a box when you deep press on a link, and shows a progress bar indicating that the content is loading. However, I know that might need to be a separate issue and outside the scope of this one. Otherwise, yes I can try to handle this in the templates so that the box is the correct size upon hover and mouse move over the link to be previewed.
I think the problem was more about the preview getting out of the screen when the content is too long and not about the preview being displayed under the cursor and then updated above the cursor (which should also be fixed but is less important honestly).
Hi @mdolr:
Noted. I just made a new commit with the following changes based on your comments:
min-height
style property set in the last commitpopupWidth
and popupHeight
in the last commitpopupHeight
variable as the height no longer needs to be known when calculating the popup positionsI still left the max-height
style property to ensure that the popup stays within the visible part of the screen, to address your requirement that the content doesn't get to be too long. However, the addition of conditionally setting a top or bottom style property ensures that the popup displays above the cursor when in the lower half of the screen, or below the cursor when in the upper part of the screen. This is because it only relies on the cursor height and not the height of the popup which isn't initially known.
Looking forward to your feedback.
Hi @mdolr,
Apologies for the delay. Could you be more specific as to how it's breaking the preview for stackoverflow links? As in what would you prefer to be the expected behaviour just so I can better understand?
Embedding a GIF to show you what I see when I hover over the links you shared:
Do you mean because I set a max-height for the popup or, with the example of the second one, the last line is clipped at the bottom of the popup?
Because of the max-height the preview's footer disappears
Thank you for the explanation; apologies for not noticing. I propose the following:
In general though, would you prefer I increase the max-height I set to the popup? My reasoning for making the max-height half of the screen height was so that in that way, the popup would always be visible on the screen.
Regardless, I look forward to hearing your recommendations that would help this PR to be approved.
Changes made:
js/base.js
innerHTML
content doesn't load yet when hovering on a link, the popup height and width are both 0 (this was why the popup would initially appear below the mouse when it should appear above the mouse). I enforced a default value of 320px for each to set an initial popup position so this wouldn't happen.topPosition
calculation so that if the mouse is in the bottom half of the screen, then the popup will appear above the mouse, otherwise it will appear below the mousepopupHeight
is initially null and can thus affect placement of the popup above or below the mouse)css/base.css
overflow: hidden
rule to truncate popup's contents that may exceed the max height