Make mention previews work on touch devices

This commit is contained in:
Toby Zerner 2015-06-24 11:47:30 +09:30
parent e53cc010e4
commit cf4074b3b8

View File

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