FIX: Timeline has to dock at the top too for long titles + banners

This commit is contained in:
Robin Ward 2016-05-25 14:19:33 -04:00
parent 1584033d7a
commit 1e3e4a95fd
No known key found for this signature in database
GPG key ID: 0E091E2B4ED1B83D
3 changed files with 10 additions and 5 deletions

View file

@ -15,6 +15,7 @@ export default MountWidget.extend(Docking, {
dockCheck(info) {
if (this.get('loading')) { return; }
const topicTop = $('.container.posts').offset().top;
const topicBottom = $('#topic-bottom').offset().top;
const $timeline = this.$('.timeline-container');
const timelineHeight = $timeline.height();
@ -23,8 +24,12 @@ export default MountWidget.extend(Docking, {
const tTop = 140;
const prev = this.dockAt;
const pos = tTop + info.offset() + timelineHeight;
if (pos > topicBottom) {
const posTop = tTop + info.offset();
const pos = posTop + timelineHeight;
if (posTop < topicTop) {
this.dockAt = 0;
} else if (pos > topicBottom) {
this.dockAt = topicBottom - timelineHeight - parentTop;
} else {
this.dockAt = null;

View file

@ -14,7 +14,7 @@ export default Ember.Mixin.create({
$(window).bind('scroll.discourse-dock', this._dockHandler);
$(document).bind('touchmove.discourse-dock', this._dockHandler);
this._dockHandler();
this.dockCheck(helper);
},
willDestroyElement() {

View file

@ -187,11 +187,11 @@ createWidget('timeline-scrollarea', {
createWidget('topic-timeline-container', {
tagName: 'div.timeline-container',
buildClasses(attrs) {
if (attrs.dockAt) { return 'timeline-docked'; }
if (attrs.dockAt !== null) { return 'timeline-docked'; }
},
buildAttributes(attrs) {
if (attrs.dockAt) {
if (attrs.dockAt !== null) {
return { style: `top: ${attrs.dockAt}px` };
};