Skip to content

Commit

Permalink
feat(seaside): #189 avoid bad alignment of news when scrolling
Browse files Browse the repository at this point in the history
close #189
  • Loading branch information
Marthym committed Dec 2, 2023
1 parent bb8f8d2 commit a5f9eca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions seaside/src/techwatch/components/newslist/NewsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ export default class NewsList extends Vue implements ScrollActivable, InfiniteSc
listener('n', event => {
event.preventDefault();
this.activateNewsCard(this.activeNews + 1);
this.scrollToActivateNews();
this.scrollToActivateNews('center');
}),
listener('k', event => {
event.preventDefault();
this.activateNewsCard(this.activeNews - 1);
this.scrollToActivateNews();
this.scrollToActivateNews('center');
}),
listener('m', event => {
event.preventDefault();
Expand Down Expand Up @@ -272,7 +272,7 @@ export default class NewsList extends Vue implements ScrollActivable, InfiniteSc
}
private markNewsRead(idx: number, mark: boolean) {
console.log("markNewsRead", idx)
console.log('markNewsRead', idx);
if (!this.isAuthenticated) {
return;
}
Expand Down Expand Up @@ -348,15 +348,15 @@ export default class NewsList extends Vue implements ScrollActivable, InfiniteSc
*
* @private
*/
private scrollToActivateNews() {
private scrollToActivateNews(block: string = 'center') {
if (this.activeNews >= this.news.length - 2 || this.activeNews < 0) {
// Stop if last news
return;
}
const current = this.news[this.activeNews + 1];
const current = this.news[this.activeNews];
this.$nextTick(() => {
this.getRefElement(current.data.id).scrollIntoView(
{ block: 'center', scrollBehavior: 'smooth' } as ScrollIntoViewOptions);
{ block: block, behavior: 'smooth' } as ScrollIntoViewOptions);
});
}
Expand Down

0 comments on commit a5f9eca

Please sign in to comment.