Skip to content
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

Bug/accordion long sections faster #121

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/elements/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class Accordion extends Component {
toggle: 'hide'
}, () => {
window.requestAnimationFrame(() => {
const transitionDuration = Math.max(this.accordionContent.current.clientHeight, 300) > 5000
? 5000
const transitionDuration = Math.max(this.accordionContent.current.clientHeight, 300) > 2000
? 1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic makes no sense
if it's gonna take longer than 2 seconds, it'll make it 1 second. else everything else can go up to 2.
both numbers should be 2000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it if the client height is more than 2000, make it 1 second? Otherwise, make it whatever seconds the height it is? (height of container, 300px = 300ms)

: Math.max(this.accordionContent.current.clientHeight, 300);

// Set fixed height (based on height of content) and set transition-duration for .ui-accordion-content-wrapper.
Expand Down Expand Up @@ -122,13 +122,17 @@ class Accordion extends Component {
window.requestAnimationFrame(() => {
this.accordionContent.current.parentNode.style.height = 0;

const closeTransitionDuration = Math.max(this.accordionContent.current.clientHeight, 300) > 2000
? 1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic makes no sense
if it's gonna take longer than 2 seconds, it'll make it 1 second. else everything else can go up to 2.
both numbers should be 2000

: Math.max(this.accordionContent.current.clientHeight, 300);

// Remove content from DOM after animation is complete
setTimeout(() => {
this.setState({
showContent: false
});
this.disableToggle = false;
}, this.accordionContent.current.clientHeight);
}, closeTransitionDuration);
});
}
}
Expand Down