mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Small timeline docking tweaks
This commit is contained in:
parent
6da097d91c
commit
f8e6d05b8d
2 changed files with 19 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
import MountWidget from 'discourse/components/mount-widget';
|
||||
import Docking from 'discourse/mixins/docking';
|
||||
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default MountWidget.extend(Docking, {
|
||||
widget: 'topic-timeline-container',
|
||||
|
@ -12,6 +13,11 @@ export default MountWidget.extend(Docking, {
|
|||
dockAt: this.dockAt };
|
||||
},
|
||||
|
||||
@observes('topic.highest_post_number')
|
||||
newPostAdded() {
|
||||
this.queueRerender(() => this.queueDockCheck());
|
||||
},
|
||||
|
||||
dockCheck(info) {
|
||||
if (this.get('loading')) { return; }
|
||||
|
||||
|
@ -31,6 +37,7 @@ export default MountWidget.extend(Docking, {
|
|||
this.dockAt = 0;
|
||||
} else if (pos > topicBottom) {
|
||||
this.dockAt = topicBottom - timelineHeight - parentTop;
|
||||
if (this.dockAt < 0) { this.dockAt = 0; }
|
||||
} else {
|
||||
this.dockAt = null;
|
||||
}
|
||||
|
|
|
@ -3,23 +3,27 @@ const helper = {
|
|||
};
|
||||
|
||||
export default Ember.Mixin.create({
|
||||
_dockHandler: null,
|
||||
queueDockCheck: null,
|
||||
|
||||
init() {
|
||||
this._super();
|
||||
this.queueDockCheck = () => {
|
||||
Ember.run.debounce(this, this.dockCheck, helper, 20);
|
||||
};
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
// Check the dock after the current run loop since reading sizes is slow
|
||||
this._dockHandler = () => Ember.run.next(() => this.dockCheck(helper));
|
||||
|
||||
$(window).bind('scroll.discourse-dock', this._dockHandler);
|
||||
$(document).bind('touchmove.discourse-dock', this._dockHandler);
|
||||
$(window).bind('scroll.discourse-dock', this.queueDockCheck);
|
||||
$(document).bind('touchmove.discourse-dock', this.queueDockCheck);
|
||||
|
||||
this.dockCheck(helper);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
$(window).unbind('scroll.discourse-dock', this._dockHandler);
|
||||
$(document).unbind('touchmove.discourse-dock', this._dockHandler);
|
||||
$(window).unbind('scroll.discourse-dock', this.queueDockCheck);
|
||||
$(document).unbind('touchmove.discourse-dock', this.queueDockCheck);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue