Panel: Bail upon opening animationComplete() if the panel has closed

Hook up animationComplete() to the wrapper, if present, and only otherwise to
the element, because the animation class is only added to the element if there
is no wrapper.

The tests now need to wait for the panel to actually open in order to hit all
the assertions, because some assertions are made only upon panelopen.

(cherry picked from commit 301f124131753a93c6ee910c731e08d5e28ebd58)

Closes gh-7264
Fixes gh-7236