From 46f2a11a80e8018725babfff314407f86f5b3438 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 22 Dec 2016 12:48:02 -0500 Subject: [PATCH] UX: Don't dock back button while dragging --- .../discourse/widgets/topic-timeline.js.es6 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 323094a1d36..026a91fa45a 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -48,12 +48,17 @@ function timelineDate(date) { createWidget('timeline-scroller', { tagName: 'div.timeline-scroller', + buildKey: () => `timeline-scroller`, + + defaultState() { + return { dragging: false }; + }, buildAttributes() { return { style: `height: ${SCROLLER_HEIGHT}px` }; }, - html(attrs) { + html(attrs, state) { const { current, total, date } = attrs; const contents = [ @@ -64,7 +69,7 @@ createWidget('timeline-scroller', { contents.push(h('div.timeline-ago', timelineDate(date))); } - if (attrs.showDockedButton) { + if (attrs.showDockedButton && !state.dragging) { contents.push(attachBackButton(this)); } let result = [ h('div.timeline-handle'), h('div.timeline-scroller-content', contents) ]; @@ -77,10 +82,12 @@ createWidget('timeline-scroller', { }, drag(e) { + this.state.dragging = true; this.sendWidgetAction('updatePercentage', e.pageY); }, dragEnd(e) { + this.state.dragging = false; if ($(e.target).is('button')) { this.sendWidgetAction('goBack'); } else {