*/
_onScroll: function (event) {
var offset = window.pageYOffset;
- console.log(offset, _lastPosition);
+
if (offset >= 300) {
if (_toTopButton.classList.contains('initiallyHidden')) {
_toTopButton.classList.remove('initiallyHidden');
var wrapper = elCreate('div');
wrapper.className = 'pageActionButton';
wrapper.name = buttonName;
- elAttr(wrapper, 'aria-hidden', 'false');
+ elAttr(wrapper, 'aria-hidden', 'true');
button.classList.add('button');
button.classList.add('buttonPrimary');
_wrapper.classList.remove('scrolledDown');
_buttons.set(buttonName, button);
+
+ // Query a layout related property to force a reflow, otherwise the transition is optimized away.
+ // noinspection BadExpressionStatementJS
+ wrapper.offsetParent;
+
+ // Toggle the visibility to force the transition to be applied.
+ elAttr(wrapper, 'aria-hidden', 'false');
+
this._renderContainer();
},
_buttons.delete(buttonName);
}
- listItem.removeEventListener('animationend', callback);
+ listItem.removeEventListener('transitionend', callback);
}
catch (e) {
// ignore errors if the element has already been removed
}
};
- listItem.addEventListener('animationend', callback);
+ listItem.addEventListener('transitionend', callback);
this.hide(buttonName);
}
-@keyframes wcfPageAction {
- 0% { visibility: visible; opacity: 0; }
- 100% { visibility: visible; opacity: 1; }
-}
-
-@keyframes wcfPageActionOut {
- 0% { visibility: visible; opacity: 1; }
- 100% { visibility: hidden; opacity: 0; }
-}
-
-@keyframes wcfPageActionRemove {
- 0% { visibility: visible; opacity: 1; }
- 60% { visibility: hidden; opacity: 0; }
- 100% { visibility: hidden; opacity: 0; max-width: 0; }
-}
-
.pageAction {
bottom: 10px;
display: flex;
.pageActionButton {
display: flex;
flex: 0 0 auto;
-
- // required to animate 'max-width' properly when removing items
- max-width: 400px;
white-space: nowrap;
&:not(:first-child) {
}
&.remove {
- animation: wcfPageActionRemove .48s;
+ opacity: 0 !important;
+ visibility: hidden !important;
}
}
.pageActionButton,
.pageActionButtonToTop {
- animation: wcfPageActionOut .24s forwards;
+ opacity: 0;
+ transition: visibility .12s linear, opacity .12s linear;
+ visibility: hidden;
&[aria-hidden="false"] {
- animation: wcfPageAction .24s;
- }
-
- &.initiallyHidden {
- animation: 0;
- visibility: hidden;
+ opacity: 1;
+ visibility: visible;
}
}
menu instead of registering any touch on a button. */
bottom: 44px;
- opacity: 1;
- transition: opacity .12s linear;
-
- &.scrolledDown {
+ &.scrolledDown .pageActionButton,
+ &.scrolledDown .pageActionButtonToTop {
opacity: 0;
+ visibility: hidden;
transition-delay: .4s;
}
}