[Glitch] Play animated custom emoji on hover
Port 7de8c51873
to glitch-soc
This commit is contained in:
parent
621590b4ab
commit
c1231a846a
5 changed files with 128 additions and 3 deletions
|
@ -4,6 +4,7 @@ import ready from 'flavours/glitch/util/ready';
|
|||
function main() {
|
||||
const IntlMessageFormat = require('intl-messageformat').default;
|
||||
const { timeAgoString } = require('flavours/glitch/components/relative_timestamp');
|
||||
const { delegate } = require('rails-ujs');
|
||||
const emojify = require('flavours/glitch/util/emoji').default;
|
||||
const { getLocale } = require('locales');
|
||||
const { messages } = getLocale();
|
||||
|
@ -23,6 +24,12 @@ function main() {
|
|||
}
|
||||
};
|
||||
|
||||
const getEmojiAnimationHandler = (swapTo) => {
|
||||
return ({ target }) => {
|
||||
target.src = target.getAttribute(swapTo);
|
||||
};
|
||||
};
|
||||
|
||||
ready(() => {
|
||||
const locale = document.documentElement.lang;
|
||||
|
||||
|
@ -94,6 +101,9 @@ function main() {
|
|||
document.head.appendChild(scrollbarWidthStyle);
|
||||
scrollbarWidthStyle.sheet.insertRule(`body.with-modals--active { margin-right: ${scrollbarWidth}px; }`, 0);
|
||||
}
|
||||
|
||||
delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
|
||||
delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue