mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
Make mention previews work on touch devices
This commit is contained in:
parent
e53cc010e4
commit
cf4074b3b8
|
@ -26,10 +26,7 @@ export default function postMentionPreviews() {
|
|||
return $('.discussion-posts .item[data-number='+number+']');
|
||||
};
|
||||
|
||||
$this.parent().hover(
|
||||
function() {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(function() {
|
||||
var showPreview = function() {
|
||||
// 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
|
||||
// in the viewport. If it is, we will "pulsate" it.
|
||||
|
@ -69,18 +66,31 @@ export default function postMentionPreviews() {
|
|||
|
||||
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() {
|
||||
clearTimeout(timeout);
|
||||
getPostElement().removeClass('pulsate');
|
||||
timeout = setTimeout(() => {
|
||||
if ($preview.hasClass('in')) {
|
||||
$preview.removeClass('in').one('transitionend', () => $preview.hide());
|
||||
timeout = setTimeout(hidePreview, 250);
|
||||
}
|
||||
}, 250);
|
||||
}
|
||||
);
|
||||
)
|
||||
.on('click', e => e.preventDefault())
|
||||
.on('touchend', e => {
|
||||
showPreview();
|
||||
e.stopPropagation();
|
||||
});
|
||||
$(document).on('touchend', hidePreview);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user