0
0
Fork 0

[Glitch] Play animated custom emoji on hover

Port 7de8c51873 to glitch-soc
This commit is contained in:
ThibG 2019-07-21 18:10:40 +02:00 committed by Thibaut Girka
parent 621590b4ab
commit c1231a846a
5 changed files with 128 additions and 3 deletions

View file

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