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

Collapse show/hide/toggle methods don't work while a previous animation is still running #16741

Closed
MiladSadinam opened this issue Jul 1, 2015 · 6 comments

Comments

@MiladSadinam
Copy link

Using

$('.collapse').collapse('show');
$('.collapse').collapse('hide');

ends up in state 'show'. The second collapse() is being ignored because the first animation is still running.

https://jsfiddle.net/fjb5r9s5/2/ demonstrates that clicking quickly the button results in wrong states.

I could reproduce this in the current versions of Chrome, Firefox and IE.

EDIT: Fixed HTML5 Validator error

@twbs-lmvtfy
Copy link

Hi @MiladSadinam!

You appear to have posted a live example (https://fiddle.jshell.net/fjb5r9s5/1/show/light/), which is always a good first step. However, according to the HTML5 validator, your example has some validation errors, which might potentially be causing your issue:

  • line 49, column 57 thru line 49, column 64: Stray end tag input.

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@cvrebert
Copy link
Collaborator

cvrebert commented Jul 1, 2015

Yes, these methods are async. You need to use the events they fire to wait for completion.
This should be documented better, like we do for the analogous tooltip/popover methods.

@cvrebert cvrebert added confirmed and removed js labels Jul 1, 2015
@cvrebert cvrebert added this to the v3.3.6 milestone Jul 1, 2015
@cvrebert cvrebert changed the title collapse() being ignored when old collapse animation is running Document that collapse show/hide methods are async Jul 1, 2015
@MiladSadinam
Copy link
Author

I see what you mean. In case of my jsfiddle example I see two solutions:

  • On button click I disable the button for the time until "shown.bs.collapse"/"hidden.bs.collapse" is triggered
  • I manually recall collapse() on "shown.bs.collapse"/"hidden.bs.collapse" when the current collapse state is "wrong".

Both solutions are not optimal. Perhaps there is a better solution? Like any collapse() call overrides previous animations?

@cvrebert
Copy link
Collaborator

cvrebert commented Jul 1, 2015

Or I suppose we could add some logic similar to

if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
to postpone the reaction to a click when (un)collapsing is already in progress.

@cvrebert cvrebert changed the title Document that collapse show/hide methods are async Collapse show/hide/toggle methods don't work while a previous animation is still running Jul 1, 2015
@cvrebert cvrebert added js and removed docs labels Jul 1, 2015
@MiladSadinam
Copy link
Author

Yeah, this makes the method definitely more intuitive. Thanks for the quick responses.

@cvrebert cvrebert added the v3 label Aug 19, 2015
@mdo mdo modified the milestones: v3.3.6, v3.3.7 Nov 24, 2015
@cvrebert cvrebert modified the milestones: v3.3.7, v3.3.8 Jul 25, 2016
@mdo
Copy link
Member

mdo commented Sep 5, 2016

Bootstrap 3 is no longer being officially developed or supported.

All work has moved onto our next major release, v4. As such, this issue or pull request is being closed as a "won't fix." For additional help and support, we recommend utilizing our community resources. Thanks for your understanding, and see you on the other side of v4!

<3,
@mdo and team

@mdo mdo closed this as completed Sep 5, 2016
@mdo mdo modified the milestone: v3.3.8 Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants