mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-25 16:04:22 -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 MountWidget from 'discourse/components/mount-widget';
|
||||||
import Docking from 'discourse/mixins/docking';
|
import Docking from 'discourse/mixins/docking';
|
||||||
|
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
export default MountWidget.extend(Docking, {
|
export default MountWidget.extend(Docking, {
|
||||||
widget: 'topic-timeline-container',
|
widget: 'topic-timeline-container',
|
||||||
|
@ -12,6 +13,11 @@ export default MountWidget.extend(Docking, {
|
||||||
dockAt: this.dockAt };
|
dockAt: this.dockAt };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@observes('topic.highest_post_number')
|
||||||
|
newPostAdded() {
|
||||||
|
this.queueRerender(() => this.queueDockCheck());
|
||||||
|
},
|
||||||
|
|
||||||
dockCheck(info) {
|
dockCheck(info) {
|
||||||
if (this.get('loading')) { return; }
|
if (this.get('loading')) { return; }
|
||||||
|
|
||||||
|
@ -31,6 +37,7 @@ export default MountWidget.extend(Docking, {
|
||||||
this.dockAt = 0;
|
this.dockAt = 0;
|
||||||
} else if (pos > topicBottom) {
|
} else if (pos > topicBottom) {
|
||||||
this.dockAt = topicBottom - timelineHeight - parentTop;
|
this.dockAt = topicBottom - timelineHeight - parentTop;
|
||||||
|
if (this.dockAt < 0) { this.dockAt = 0; }
|
||||||
} else {
|
} else {
|
||||||
this.dockAt = null;
|
this.dockAt = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,23 +3,27 @@ const helper = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Ember.Mixin.create({
|
export default Ember.Mixin.create({
|
||||||
_dockHandler: null,
|
queueDockCheck: null,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._super();
|
||||||
|
this.queueDockCheck = () => {
|
||||||
|
Ember.run.debounce(this, this.dockCheck, helper, 20);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
// Check the dock after the current run loop since reading sizes is slow
|
$(window).bind('scroll.discourse-dock', this.queueDockCheck);
|
||||||
this._dockHandler = () => Ember.run.next(() => this.dockCheck(helper));
|
$(document).bind('touchmove.discourse-dock', this.queueDockCheck);
|
||||||
|
|
||||||
$(window).bind('scroll.discourse-dock', this._dockHandler);
|
|
||||||
$(document).bind('touchmove.discourse-dock', this._dockHandler);
|
|
||||||
|
|
||||||
this.dockCheck(helper);
|
this.dockCheck(helper);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super();
|
this._super();
|
||||||
$(window).unbind('scroll.discourse-dock', this._dockHandler);
|
$(window).unbind('scroll.discourse-dock', this.queueDockCheck);
|
||||||
$(document).unbind('touchmove.discourse-dock', this._dockHandler);
|
$(document).unbind('touchmove.discourse-dock', this.queueDockCheck);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue