Merge pull request #4590 from xfalcox/css-highligth
Use CSS animations for post and topic highlights
This commit is contained in:
commit
81956cb1d6
|
@ -5,16 +5,10 @@ import { selectedText } from 'discourse/lib/utilities';
|
||||||
import { observes } from 'ember-addons/ember-computed-decorators';
|
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
function highlight(postNumber) {
|
function highlight(postNumber) {
|
||||||
const $contents = $(`#post_${postNumber} .topic-body`),
|
const $contents = $(`#post_${postNumber} .topic-body`);
|
||||||
origColor = $contents.data('orig-color') || $contents.css('backgroundColor');
|
|
||||||
|
|
||||||
$contents.data("orig-color", origColor)
|
$contents.addClass('highlighted');
|
||||||
.addClass('highlighted')
|
$contents.on('animationend', () => $contents.removeClass('highlighted'));
|
||||||
.stop()
|
|
||||||
.animate({ backgroundColor: origColor }, 2500, 'swing', function() {
|
|
||||||
$contents.removeClass('highlighted');
|
|
||||||
$contents.css({'background-color': ''});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ember.Component.extend(AddArchetypeClass, Scrolling, {
|
export default Ember.Component.extend(AddArchetypeClass, Scrolling, {
|
||||||
|
|
|
@ -128,14 +128,11 @@ export default Ember.Component.extend(bufferedRender({
|
||||||
|
|
||||||
highlight(opts = { isLastViewedTopic: false }) {
|
highlight(opts = { isLastViewedTopic: false }) {
|
||||||
const $topic = this.$();
|
const $topic = this.$();
|
||||||
const originalCol = $topic.css('backgroundColor');
|
|
||||||
$topic
|
$topic
|
||||||
.addClass('highlighted')
|
.addClass('highlighted')
|
||||||
.attr('data-islastviewedtopic', opts.isLastViewedTopic)
|
.attr('data-islastviewedtopic', opts.isLastViewedTopic);
|
||||||
.stop()
|
|
||||||
.animate({ backgroundColor: originalCol }, 2500, 'swing', function() {
|
$topic.on('animationend', () => $topic.removeClass('highlighted'));
|
||||||
$topic.removeClass('highlighted');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_highlightIfNeeded: function() {
|
_highlightIfNeeded: function() {
|
||||||
|
|
|
@ -339,3 +339,12 @@ body {
|
||||||
span.relative-date {
|
span.relative-date {
|
||||||
white-space:nowrap;
|
white-space:nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes background-fade-highlight {
|
||||||
|
0% {
|
||||||
|
background-color: dark-light-diff($tertiary, $secondary, 85%, -65%);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ aside.quote {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
&.highlighted {
|
&.highlighted {
|
||||||
background-color: dark-light-diff($tertiary, $secondary, 85%, -65%);
|
animation: background-fade-highlight 2.5s ease-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
> tbody > tr {
|
> tbody > tr {
|
||||||
&.highlighted {
|
&.highlighted {
|
||||||
background-color: dark-light-diff($tertiary, $secondary, 85%, -65%);
|
animation: background-fade-highlight 2.5s ease-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
button.bulk-select {
|
button.bulk-select {
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
> tbody > tr {
|
> tbody > tr {
|
||||||
&.highlighted {
|
&.highlighted {
|
||||||
background-color: dark-light-choose(scale-color($tertiary, $lightness: 85%), scale-color($tertiary, $lightness: -55%));
|
animation: background-fade-highlight 2.5s ease-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue