-
Notifications
You must be signed in to change notification settings - Fork 123
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
Add conditional panel closing transition based on height #1965
Conversation
…han a fixed height Better readability when chunky viewports are not "dragged" up to panel's start.
Hi @eeliana, thank you for contributing! Wonder if it is possible for you to add the two cases you showed in the gif in https://github.com/MarkBind/markbind/tree/master/packages/cli/test/functional/test_site so that this behavior is properly noted down in our functional test suite? |
@ang-zeyu do you have any examples of disorienting panels when closing? Looking at some of the panels in |
@tlylt was trying out the panels in the 2103 pages https://nus-cs2103-ay2122s2.github.io/website/schedule/week3/topics.html, which can be really long. The problem is worse on slower + mobile devices as well where the animation gets dragged out beyond the specified duration / becomes really prominent. Might just be me though (I'm not a huge fan of large animations in regular day-to-day things - e.g. mac's mission control), perhaps we can get @jonahtanjz's input too. I should also add that its more so disorienting for me only when the scroll animation takes place (the top of the panel is above the viewport), combined with the panel's height transition. If in agreement here perhaps, instead of just a fixed height, we can also add:
|
@@ -141,6 +141,9 @@ export default { | |||
Thus, we need to reset the maxHeight to its current height for collapse transition to work. | |||
*/ | |||
this.$refs.panel.style.maxHeight = `${this.$refs.panel.scrollHeight}px`; | |||
if (this.$refs.panel.scrollHeight > 300) { | |||
this.$refs.panel.style.transition = 'max-height 0s ease-in-out'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On that note, I noticed the jQuery scroll animation isn't disabled too, was thinking it should (sorry that the issue description wasn't clear enough!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tlylt @eeliana in case you missed this.
It's nowhere near as disorienting with the panel height transition removed, but I'm not entirely sure if this should be removed as well. (personally, still favouring removal as there is a slight time lag till the scroll takes place)
If it looks ok / better to you guys feel free to keep it :)
Agree with this. I think the panel transition is fine as long as the header is within the viewport. I feel that it would be nice to have some transition when the panel is closed rather than it closing abruptly. The transition only becomes disorienting when the panel is really long and causes the page to scroll when it is collapsed: CS2103_T.-.Week.3.-.Topics.-.Google.Chrome.2022-07-17.19-36-14.mp4 |
Hi @eeliana, you may need to address the functional test failures (See this part https://github.com/MarkBind/markbind/runs/7374887371?check_suite_focus=true) Read https://markbind-master.netlify.app/devguide/workflow#updating-and-writing-tests to find out how to update the test snapshot. |
Great work with this PR! Just a tip for updating tests:
|
Hi, I have done this and I don't see the same issue after |
i don’t think you have updated the snapshot, have you tried running npm run updatetest? What @ong6 was referring to is that you should git add only the relevant generated files, and discard the changes to image files (and any other files that at the moment are incorrectly flagged) Also, you should be able to run “npm run test” locally to check if the tests are passing locally , if they aren’t then it’s unlikely that they will pass in CI |
Yup, I ran |
Yes you will need to commit the generated files, they are generally in packages/cli/test/functional/test_site/expected take note of the caveat in #1937 |
@ang-zeyu I am not sure if the disorienting issue can be resolved even by removing the transition effect. Trying it out locally with the changes from this branch: For pages like the one below, with a panel that is not too long, I prefer the previous closing animation since it looks fine to me. With the new changes, the closing is more abrupt and it may be a little surprising if another shorter panel nearby has an animation and suddenly the next panel doesn't have it
What do you think? |
@@ -141,6 +141,9 @@ export default { | |||
Thus, we need to reset the maxHeight to its current height for collapse transition to work. | |||
*/ | |||
this.$refs.panel.style.maxHeight = `${this.$refs.panel.scrollHeight}px`; | |||
if (this.$refs.panel.scrollHeight > window.innerHeight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ang-zeyu I am not sure if the disorienting issue can be resolved even by removing the transition effect. Trying it out locally with the changes from this branch:
I don't think this implementation is correct, @tlylt the case in your gif shouldn't occur ⬇️
if top of panel beyond viewport (I think there's some existing checks for this too)
the relevant existing check is here https://github.com/MarkBind/markbind/blob/master/packages/vue-components/src/panels/PanelBase.js#L147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For pages like the one below, with a panel that is not too long, I prefer the previous closing animation since it looks fine to me. With the new changes, the closing is more abrupt and it may be a little surprising if another shorter panel nearby has an animation and suddenly the next panel doesn't have it
If corrected, does it account for the 2 links you linked too?
If not, we could try #1965 (comment), or even remove the closing transitions completely for UX consistency (⭐I think this might be better based on what you've mentioned⭐).
Again this is all very subjective, and I'm not huge fan of large animations (fwiw I'm the original implementor of this feature, haven't found the closing transitions anything apart from dizzying)
Our primary issue back then was also that the page did not scroll back up to the top of the panel at all, much less the transitions which was a cool "afterthought" =P
If agreed here perhaps we should just remove closing transitions completely (including the jquery scroll).
@damithc @MarkBind/active-devs can chime in too.
maybe give a thumbs up 👍 or 👎 on this comment to get a consensus. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK to remove the transition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eeliana based on the 👍 so far, I think we can go ahead with replacing any and all closing transitions (including the jquery scroll) with an "instant snap" back to the top of the panel. The opening ones can be kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If corrected, does it account for the 2 links you linked too?
Yes if all closing transitions are removed, then I think the behavior is uniform and I am ok with that.
I don't think this implementation is correct, @tlylt the case in your gif shouldn't occur ⬇️
Re looking at this again, may need your advice on if there's anything special going on here... So the case in my gif is one that the closed panels are near the bottom of the page. When opening or closing, the height of the page could reduce or increase such that the panel moves away from the original position. Base on my observation, whether before or after the latest change done by @eeliana, it seems like at times the panel could move away from the original position and result in slight disorienting effect, or somehow it won't. Here's a few recordings:
-
You can see that the first closing of "Guideline: Maximum readability" result in the panel heading moving, while the open and closing of the subsequent times didn't cause that (which is what we want to achieve?). This is done with the change in this PR applied
-
You can also experiment with this on https://nus-cs2103-ay2021s1.github.io/website/se-book-adapted/chapters/codeQuality.html which is the original behavior:
a) works fine (seems like I am able to trigger this, by closing the panels one by one, avoiding any scrolling before I close all the panels)
b) doesn't really work well (seems like I am able to trigger this, by scrolling around, before closing the panels)
@eeliana Please feel free to experiment a little and follow up on this since it's your PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re looking at this again, may need your advice on if there's anything special going on here...
I actually thought the issue you wanted to show in your gif was that the closing transition was not activating previously, in that case it should since the top of the panel is in view. (the check isn't correct for that)
Yes if all closing transitions are removed, then I think the behavior is uniform and I am ok with that.
But not so much relevant since we're going with this now. 😶
Re looking at this again, may need your advice on if there's anything special going on here...
This seems separate, let's put up a another issue for this.
Since its occuring only on the first open, likely:
packages/cli/test/functional/test_site/testPanelsClosingTransition.md
Outdated
Show resolved
Hide resolved
// To enable behaviour of auto window scrolling during panel collapse | ||
if (this.$el.getBoundingClientRect().top < 0) { | ||
const headerHeight = jQuery('header[sticky]').height() || 0; | ||
jQuery('html').animate({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's update this with an instant scroll; this was the key issue we had back then. Again the transitions are just a "cool afterthought" =P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic here needs to be updated too https://github.com/MarkBind/markbind/blob/master/packages/vue-components/src/panels/MinimalPanel.vue#L123 (try collapsing a minimal type panel, the header would disappear)
} else { | ||
// Expand panel | ||
this.$refs.panel.style.maxHeight = `${this.$refs.panel.scrollHeight}px`; | ||
this.$refs.panel.style.transition = 'max-height 0.5s ease-in-out'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 could this go before the previous line? I don't think there's any browser guarantees here but it would be best to ensure the sequence of operations on our side too.
requestAnimationFrame(() => { | ||
// To enable behaviour of auto window scrolling during panel collapse | ||
if (this.$el.getBoundingClientRect().top < 0) { | ||
const headerHeight = jQuery('header[sticky]').height() || 0; | ||
jQuery('html').animate({ | ||
scrollTop: window.scrollY + this.$el.getBoundingClientRect().top - headerHeight - 3, | ||
}, 500, 'swing'); | ||
}, 0, 'swing'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not remove the animate
?
.scrollTop = ...
Hi @eeliana, great work on this PR. Checking if you are still keen to implement the last few comments/fixes as requested? |
cc @MarkBind/contributors pls help support this if possible, it's near completion. |
@tlylt I don't seem to have permission to edit the PR. |
Pls checkout from this branch and raise a follow-up PR instead. |
Closing after work is merged in #2159, thank you @eeliana and @yucheng11122017! |
What is the purpose of this pull request?
Resolves #1836
Overview of changes:
Only activate closing transition for panels when the height is below a certain height.
Anything you'd like to highlight/discuss:
Only adjusted closing transitions, opening transition remains the same.
Fixed height is 300 for now, can be adjusted.
Testing instructions:
Create a test site and put chunkier placeholder text into the panel to see the difference in closing transitions.
Proposed commit message: (wrap lines at 72 characters)
Add conditional panel closing transition based on height
Checklist: ☑️