FIX: Fix timeline dragging on iOS. Temporary fix for bottom of page

This commit is contained in:
Robin Ward 2016-05-19 17:55:10 -04:00
parent fc4dc76f42
commit 8a047e2708
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
2 changed files with 16 additions and 4 deletions

View File

@ -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));

View File

@ -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` };
};