Skip to content

Commit fb82a2b

Browse files
committed
Merge branch 'patching-v0.27' into release
2 parents 5b46493 + d6456e9 commit fb82a2b

4 files changed

Lines changed: 33 additions & 22 deletions

File tree

resources/assets/js/components/page-comments.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ class PageComments {
2626

2727
handleAction(event) {
2828
let actionElem = event.target.closest('[action]');
29+
2930
if (event.target.matches('a[href^="#"]')) {
3031
const id = event.target.href.split('#')[1];
3132
scrollAndHighlightElement(document.querySelector('#' + id));
3233
}
34+
3335
if (actionElem === null) return;
3436
event.preventDefault();
3537

resources/assets/js/services/animations.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
/**
2+
* Used in the function below to store references of clean-up functions.
3+
* Used to ensure only one transitionend function exists at any time.
4+
* @type {WeakMap<object, any>}
5+
*/
6+
const animateStylesCleanupMap = new WeakMap();
7+
18
/**
29
* Fade out the given element.
310
* @param {Element} element
411
* @param {Number} animTime
512
* @param {Function|null} onComplete
613
*/
714
export function fadeOut(element, animTime = 400, onComplete = null) {
15+
cleanupExistingElementAnimation(element);
816
animateStyles(element, {
917
opacity: ['1', '0']
1018
}, animTime, () => {
@@ -19,6 +27,7 @@ export function fadeOut(element, animTime = 400, onComplete = null) {
1927
* @param {Number} animTime
2028
*/
2129
export function slideUp(element, animTime = 400) {
30+
cleanupExistingElementAnimation(element);
2231
const currentHeight = element.getBoundingClientRect().height;
2332
const computedStyles = getComputedStyle(element);
2433
const currentPaddingTop = computedStyles.getPropertyValue('padding-top');
@@ -41,6 +50,7 @@ export function slideUp(element, animTime = 400) {
4150
* @param {Number} animTime - Animation time in ms
4251
*/
4352
export function slideDown(element, animTime = 400) {
53+
cleanupExistingElementAnimation(element);
4454
element.style.display = 'block';
4555
const targetHeight = element.getBoundingClientRect().height;
4656
const computedStyles = getComputedStyle(element);
@@ -56,13 +66,6 @@ export function slideDown(element, animTime = 400) {
5666
animateStyles(element, animStyles, animTime);
5767
}
5868

59-
/**
60-
* Used in the function below to store references of clean-up functions.
61-
* Used to ensure only one transitionend function exists at any time.
62-
* @type {WeakMap<object, any>}
63-
*/
64-
const animateStylesCleanupMap = new WeakMap();
65-
6669
/**
6770
* Animate the css styles of an element using FLIP animation techniques.
6871
* Styles must be an object where the keys are style properties, camelcase, and the values
@@ -84,23 +87,28 @@ function animateStyles(element, styles, animTime = 400, onComplete = null) {
8487
}
8588
element.style.transition = null;
8689
element.removeEventListener('transitionend', cleanup);
90+
animateStylesCleanupMap.delete(element);
8791
if (onComplete) onComplete();
8892
};
8993

9094
setTimeout(() => {
91-
requestAnimationFrame(() => {
92-
element.style.transition = `all ease-in-out ${animTime}ms`;
93-
for (let style of styleNames) {
94-
element.style[style] = styles[style][1];
95-
}
95+
element.style.transition = `all ease-in-out ${animTime}ms`;
96+
for (let style of styleNames) {
97+
element.style[style] = styles[style][1];
98+
}
9699

97-
if (animateStylesCleanupMap.has(element)) {
98-
const oldCleanup = animateStylesCleanupMap.get(element);
99-
element.removeEventListener('transitionend', oldCleanup);
100-
}
100+
element.addEventListener('transitionend', cleanup);
101+
animateStylesCleanupMap.set(element, cleanup);
102+
}, 15);
103+
}
101104

102-
element.addEventListener('transitionend', cleanup);
103-
animateStylesCleanupMap.set(element, cleanup);
104-
});
105-
}, 10);
105+
/**
106+
* Run the active cleanup action for the given element.
107+
* @param {Element} element
108+
*/
109+
function cleanupExistingElementAnimation(element) {
110+
if (animateStylesCleanupMap.has(element)) {
111+
const oldCleanup = animateStylesCleanupMap.get(element);
112+
oldCleanup();
113+
}
106114
}

resources/assets/sass/styles.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ $btt-size: 40px;
253253
.list-sort {
254254
display: inline-grid;
255255
margin-left: $-s;
256-
grid-template-columns: 120px 40px;
256+
grid-template-columns: minmax(120px, max-content) 40px;
257+
font-size: 0.9rem;
257258
border: 2px solid #DDD;
258259
border-radius: 4px;
259260
}

resources/views/comments/comment.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<button type="button" dropdown-toggle aria-haspopup="true" aria-expanded="false" class="text-button" title="{{ trans('common.delete') }}">@icon('delete')</button>
3232
<ul class="dropdown-menu" role="menu">
3333
<li class="px-m text-small text-muted pb-s">{{trans('entities.comment_delete_confirm')}}</li>
34-
<li><a action="delete" href="#" class="text-button text-neg" >@icon('delete'){{ trans('common.delete') }}</a></li>
34+
<li><button action="delete" type="button" class="text-button text-neg" >@icon('delete'){{ trans('common.delete') }}</button></li>
3535
</ul>
3636
</div>
3737
@endif

0 commit comments

Comments
 (0)