Commit 0c46b3b8 authored by Regis's avatar Regis

use computed css class for animations

parent c59f80ff
...@@ -29,15 +29,22 @@ export default { ...@@ -29,15 +29,22 @@ export default {
}, },
}); });
const defaultFlags = {
pre: true,
pulse: false,
};
return { return {
poll, poll,
apiData: {}, apiData: {},
tasks: '0 of 0',
title: null, title: null,
titleText: '', titleText: '',
tasks: '0 of 0', titleFlag: defaultFlags,
description: null, description: null,
descriptionText: '', descriptionText: '',
descriptionChange: false, descriptionChange: false,
descriptionFlag: defaultFlags,
timeAgoEl: $('.issue_edited_ago'), timeAgoEl: $('.issue_edited_ago'),
titleEl: document.querySelector('title'), titleEl: document.querySelector('title'),
}; };
...@@ -51,11 +58,9 @@ export default { ...@@ -51,11 +58,9 @@ export default {
tasks(this.apiData, this.tasks); tasks(this.apiData, this.tasks);
}, },
elementsToVisualize(noTitleChange, noDescriptionChange) { elementsToVisualize(noTitleChange, noDescriptionChange) {
const elementStack = [];
if (!noTitleChange) { if (!noTitleChange) {
this.titleText = this.apiData.title_text; this.titleText = this.apiData.title_text;
elementStack.push(this.$refs['issue-title']); this.titleFlag = { pre: true, pulse: false };
} }
if (!noDescriptionChange) { if (!noDescriptionChange) {
...@@ -63,35 +68,24 @@ export default { ...@@ -63,35 +68,24 @@ export default {
this.descriptionChange = true; this.descriptionChange = true;
this.updateTaskHTML(); this.updateTaskHTML();
this.tasks = this.apiData.task_status; this.tasks = this.apiData.task_status;
elementStack.push(this.$refs['issue-content-container-gfm-entry']); this.descriptionFlag = { pre: true, pulse: false };
} }
elementStack.forEach((element) => { return { noTitleChange, noDescriptionChange };
if (element) {
element.classList.remove('issue-realtime-trigger-pulse');
element.classList.add('issue-realtime-pre-pulse');
}
});
return elementStack;
}, },
setTabTitle() { setTabTitle() {
const currentTabTitleScope = this.titleEl.innerText.split('·'); const currentTabTitleScope = this.titleEl.innerText.split('·');
currentTabTitleScope[0] = `${this.titleText} (#${this.apiData.issue_number}) `; currentTabTitleScope[0] = `${this.titleText} (#${this.apiData.issue_number}) `;
this.titleEl.innerText = currentTabTitleScope.join('·'); this.titleEl.innerText = currentTabTitleScope.join('·');
}, },
animate(title, description, elementsToVisualize) { animate(title, description) {
this.title = title; this.title = title;
this.description = description; this.description = description;
this.setTabTitle(); this.setTabTitle();
this.$nextTick(() => { this.$nextTick(() => {
elementsToVisualize.forEach((element) => { this.titleFlag = { pre: false, pulse: true };
if (element) { this.descriptionFlag = { pre: false, pulse: true };
element.classList.remove('issue-realtime-pre-pulse');
element.classList.add('issue-realtime-trigger-pulse');
}
});
}); });
}, },
triggerAnimation() { triggerAnimation() {
...@@ -110,12 +104,8 @@ export default { ...@@ -110,12 +104,8 @@ export default {
*/ */
if (noTitleChange && noDescriptionChange) return; if (noTitleChange && noDescriptionChange) return;
const elementsToVisualize = this.elementsToVisualize( this.elementsToVisualize(noTitleChange, noDescriptionChange);
noTitleChange, this.animate(title, description);
noDescriptionChange,
);
this.animate(title, description, elementsToVisualize);
}, },
updateEditedTimeAgo() { updateEditedTimeAgo() {
const toolTipTime = gl.utils.formatDate(this.apiData.updated_at); const toolTipTime = gl.utils.formatDate(this.apiData.updated_at);
...@@ -128,6 +118,18 @@ export default { ...@@ -128,6 +118,18 @@ export default {
descriptionClass() { descriptionClass() {
return `description ${this.canUpdateIssue} is-task-list-enabled`; return `description ${this.canUpdateIssue} is-task-list-enabled`;
}, },
titleAnimationCss() {
return {
'title issue-realtime-pre-pulse': this.titleFlag.pre,
'title issue-realtime-trigger-pulse': this.titleFlag.pulse,
};
},
descriptionAnimationCss() {
return {
'wiki issue-realtime-pre-pulse': this.descriptionFlag.pre,
'wiki issue-realtime-trigger-pulse': this.descriptionFlag.pulse,
};
},
}, },
created() { created() {
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
...@@ -166,7 +168,7 @@ export default { ...@@ -166,7 +168,7 @@ export default {
<template> <template>
<div> <div>
<h2 <h2
class="title issue-realtime-trigger-pulse" :class="titleAnimationCss"
ref="issue-title" ref="issue-title"
v-html="title" v-html="title"
> >
...@@ -176,7 +178,7 @@ export default { ...@@ -176,7 +178,7 @@ export default {
v-if="description" v-if="description"
> >
<div <div
class="wiki issue-realtime-trigger-pulse" :class="descriptionAnimationCss"
v-html="description" v-html="description"
ref="issue-content-container-gfm-entry" ref="issue-content-container-gfm-entry"
> >
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment