From 06a5df63d37dad74050916775f5c956973c7736a Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 27 May 2016 15:37:19 -0400 Subject: [PATCH] UX: Have the timeline dock slightly below where the buttons would go --- .../components/topic-timeline.js.es6 | 12 ++++++--- .../javascripts/discourse/templates/topic.hbs | 27 +++++++++---------- .../discourse/widgets/topic-timeline.js.es6 | 8 ++++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 index e27f74f8a01..e0872e275fc 100644 --- a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 @@ -4,13 +4,15 @@ import { observes } from 'ember-addons/ember-computed-decorators'; export default MountWidget.extend(Docking, { widget: 'topic-timeline-container', + dockBottom: null, dockAt: null, buildArgs() { return { topic: this.get('topic'), topicTrackingState: this.topicTrackingState, enteredIndex: this.get('enteredIndex'), - dockAt: this.dockAt }; + dockAt: this.dockAt, + dockBottom: this.dockBottom }; }, @observes('topic.highest_post_number') @@ -25,7 +27,7 @@ export default MountWidget.extend(Docking, { const topicBottom = $('#topic-bottom').offset().top; const $timeline = this.$('.timeline-container'); const timelineHeight = $timeline.height(); - const parentTop = $('.posts-wrapper').offset().top; + const footerHeight = $('.timeline-footer-controls').outerHeight(true) || 0; const tTop = 140; @@ -33,10 +35,12 @@ export default MountWidget.extend(Docking, { const posTop = tTop + info.offset(); const pos = posTop + timelineHeight; + this.dockBottom = false; if (posTop < topicTop) { - this.dockAt = 0; + this.dockAt = topicTop; } else if (pos > topicBottom) { - this.dockAt = topicBottom - timelineHeight - parentTop; + this.dockAt = (topicBottom - timelineHeight) + footerHeight; + this.dockBottom = true; if (this.dockAt < 0) { this.dockAt = 0; } } else { this.dockAt = null; diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index b4ba09db5af..7855b009722 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -66,24 +66,23 @@
{{partial "selected-posts"}}
+ {{#topic-navigation as |showTimeline|}} + {{#if showTimeline}} + {{topic-timeline topic=model + enteredIndex=enteredIndex + loading=model.postStream.loading + delegated=topicDelegated}} + {{else}} + {{topic-admin-menu-button topic=model fixed="true" delegated=topicDelegated}} + {{/if}} + + {{topic-progress topic=model delegated=topicDelegated showTimeline=showTimeline}} + {{/topic-navigation}}
+
- - {{#topic-navigation as |showTimeline|}} - {{#if showTimeline}} - {{topic-timeline topic=model - enteredIndex=enteredIndex - loading=model.postStream.loading - delegated=topicDelegated}} - {{else}} - {{topic-admin-menu-button topic=model fixed="true" delegated=topicDelegated}} - {{/if}} - - {{topic-progress topic=model delegated=topicDelegated showTimeline=showTimeline}} - {{/topic-navigation}} - {{conditional-loading-spinner condition=model.postStream.loadingAbove}} {{plugin-outlet "topic-above-posts"}} diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 3adc5286796..b3af7d60c0f 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -187,8 +187,12 @@ createWidget('timeline-scrollarea', { createWidget('topic-timeline-container', { tagName: 'div.timeline-container', buildClasses(attrs) { - if (attrs.dockAt !== null) { - return attrs.dockAt > 0 ? 'timeline-docked timeline-docked-bottom' : 'timeline-docked'; + if (attrs.dockAt) { + const result = ['timeline-docked']; + if (attrs.dockBottom) { + result.push('timeline-docked-bottom'); + } + return result.join(' '); } },