From 4963d4d624145f7131c0f10584940a6d36970230 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 20 May 2016 12:13:10 -0400 Subject: [PATCH] UX: Don't animate timeline when first entering a topic --- .../discourse/initializers/live-development.js.es6 | 6 ++++++ .../javascripts/discourse/widgets/topic-timeline.js.es6 | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/initializers/live-development.js.es6 b/app/assets/javascripts/discourse/initializers/live-development.js.es6 index a7318b1a7..a3c8afa51 100644 --- a/app/assets/javascripts/discourse/initializers/live-development.js.es6 +++ b/app/assets/javascripts/discourse/initializers/live-development.js.es6 @@ -1,4 +1,5 @@ import loadScript from 'discourse/lib/load-script'; +import DiscourseURL from 'discourse/lib/url'; // Use the message bus for live reloading of components for faster development. export default { @@ -30,6 +31,11 @@ export default { }); }); + // Useful to export this for debugging purposes + if (Discourse.Environment === 'development' && !Ember.testing) { + window.DiscourseURL = DiscourseURL; + } + // Observe file changes messageBus.subscribe("/file-change", function(data) { if (Handlebars.compile && !Ember.TEMPLATES.empty) { diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 590601138..c05b5f570 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -83,7 +83,7 @@ createWidget('timeline-scrollarea', { }, defaultState() { - return { percentage: 0, scrolledPost: 1 }; + return { percentage: null, scrolledPost: 1 }; }, position() { @@ -124,6 +124,8 @@ createWidget('timeline-scrollarea', { state.scrolledPost = position.current; const percentage = state.percentage; + if (percentage === null) { return; } + const before = SCROLLAREA_REMAINING * percentage; const after = (SCROLLAREA_HEIGHT - before) - SCROLLER_HEIGHT; @@ -133,7 +135,6 @@ createWidget('timeline-scrollarea', { this.attach('timeline-padding', { height: after }) ]; - if (position.lastRead && position.lastRead < attrs.topic.posts_count) { const lastReadTop = Math.round(position.lastReadPercentage * SCROLLAREA_HEIGHT); if (lastReadTop > (before + SCROLLER_HEIGHT)) {