mirror of
https://github.com/flarum/core.git
synced 2025-08-02 22:47:33 +02:00
Make mention previews work on touch devices
This commit is contained in:
@@ -26,10 +26,7 @@ export default function postMentionPreviews() {
|
|||||||
return $('.discussion-posts .item[data-number='+number+']');
|
return $('.discussion-posts .item[data-number='+number+']');
|
||||||
};
|
};
|
||||||
|
|
||||||
$this.parent().hover(
|
var showPreview = function() {
|
||||||
function() {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = setTimeout(function() {
|
|
||||||
// When the user hovers their mouse over the mention, look for the
|
// When the user hovers their mouse over the mention, look for the
|
||||||
// post that it's referring to in the stream, and determine if it's
|
// post that it's referring to in the stream, and determine if it's
|
||||||
// in the viewport. If it is, we will "pulsate" it.
|
// in the viewport. If it is, we will "pulsate" it.
|
||||||
@@ -69,18 +66,31 @@ export default function postMentionPreviews() {
|
|||||||
|
|
||||||
setTimeout(() => $preview.off('transitionend').addClass('in'));
|
setTimeout(() => $preview.off('transitionend').addClass('in'));
|
||||||
}
|
}
|
||||||
}, 500);
|
};
|
||||||
|
var hidePreview = () => {
|
||||||
|
getPostElement().removeClass('pulsate');
|
||||||
|
if ($preview.hasClass('in')) {
|
||||||
|
$preview.removeClass('in').one('transitionend', () => $preview.hide());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$this.parent().hover(
|
||||||
|
function() {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(showPreview, 500);
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
getPostElement().removeClass('pulsate');
|
getPostElement().removeClass('pulsate');
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(hidePreview, 250);
|
||||||
if ($preview.hasClass('in')) {
|
|
||||||
$preview.removeClass('in').one('transitionend', () => $preview.hide());
|
|
||||||
}
|
}
|
||||||
}, 250);
|
)
|
||||||
}
|
.on('click', e => e.preventDefault())
|
||||||
);
|
.on('touchend', e => {
|
||||||
|
showPreview();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
$(document).on('touchend', hidePreview);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user