From 8a047e27088f5094dfcb7a8a51b27599b2470308 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 19 May 2016 17:55:10 -0400 Subject: [PATCH] FIX: Fix timeline dragging on iOS. Temporary fix for bottom of page --- .../javascripts/discourse/widgets/hooks.js.es6 | 17 +++++++++++++---- .../discourse/widgets/topic-timeline.js.es6 | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/hooks.js.es6 b/app/assets/javascripts/discourse/widgets/hooks.js.es6 index b9c8c05f6d1..14b7cd0d962 100644 --- a/app/assets/javascripts/discourse/widgets/hooks.js.es6 +++ b/app/assets/javascripts/discourse/widgets/hooks.js.es6 @@ -51,11 +51,12 @@ function findWidget(node, attrName) { let _watchingDocument = false; let _dragging; -const DRAG_NAME = "mousemove.discourse-widget-drag"; +const DRAG_NAME = "mousemove.discourse-widget-drag"; +const DRAG_NAME_TOUCH = "touchmove.discourse-widget-drag"; function cancelDrag() { $('body').removeClass('widget-dragging'); - $(document).off(DRAG_NAME); + $(document).off(DRAG_NAME).off(DRAG_NAME_TOUCH); if (_dragging) { if (_dragging.dragEnd) { _dragging.dragEnd(); } @@ -66,17 +67,25 @@ function cancelDrag() { WidgetClickHook.setupDocumentCallback = function() { if (_watchingDocument) { return; } - $(document).on('mousedown.disource-widget', e => { + $(document).on('mousedown.discource-widget-drag, touchstart.discourse-widget-drag', e => { cancelDrag(); const widget = findWidget(e.target, DRAG_ATTRIBUTE_NAME); if (widget) { + e.preventDefault(); + e.stopPropagation(); _dragging = widget; $('body').addClass('widget-dragging'); $(document).on(DRAG_NAME, dragE => widget.drag(dragE)); + $(document).on(DRAG_NAME_TOUCH, dragE => { + const tt = dragE.originalEvent.targetTouches[0]; + if (tt) { + widget.drag(tt); + } + }); } }); - $(document).on('mouseup.discourse-widget-drag', () => cancelDrag()); + $(document).on('mouseup.discourse-widget-drag, touchend.discourse-widget-drag', () => cancelDrag()); $(document).on('click.discourse-widget', e => { nodeCallback(e.target, CLICK_ATTRIBUTE_NAME, w => w.click(e)); diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 590601138fa..8182655de20 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -178,6 +178,9 @@ createWidget('topic-timeline-container', { buildAttributes(attrs) { if (attrs.dockAt) { + if (this.capabilities.isIOS) { + return { style: `display: none` }; + } return { style: `top: ${attrs.dockAt}px` }; };