mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 16:43:40 +08:00
FEATURE: automatically unpin topic when user reaches bottom
This commit is contained in:
parent
ff0c12efa2
commit
7436a3feb3
|
@ -4,6 +4,7 @@ import ClickTrack from 'discourse/lib/click-track';
|
|||
import { listenForViewEvent } from 'discourse/lib/app-events';
|
||||
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
||||
import Scrolling from 'discourse/mixins/scrolling';
|
||||
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
||||
|
||||
const TopicView = Ember.View.extend(AddCategoryClass, AddArchetypeClass, Scrolling, {
|
||||
templateName: 'topic',
|
||||
|
@ -117,6 +118,14 @@ const TopicView = Ember.View.extend(AddCategoryClass, AddArchetypeClass, Scrolli
|
|||
headerController.set('showExtraInfo', topic.get('postStream.firstPostNotLoaded'));
|
||||
}
|
||||
|
||||
// automatically unpin topics when the user reaches the bottom
|
||||
if (topic.get("pinned")) {
|
||||
const $topicFooterButtons = $("#topic-footer-buttons");
|
||||
if ($topicFooterButtons.length > 0 && isElementInViewport($topicFooterButtons)) {
|
||||
Em.run.next(() => topic.clearPin());
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger a scrolled event
|
||||
this.appEvents.trigger('topic:scrolled', offset);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user