Skip to content

Instantly share code, notes, and snippets.

@KiitoX
Created June 20, 2016 08:16
Show Gist options
  • Save KiitoX/ac1706e3d0f8b65605d9f6f3c8968d44 to your computer and use it in GitHub Desktop.
Save KiitoX/ac1706e3d0f8b65605d9f6f3c8968d44 to your computer and use it in GitHub Desktop.
lyrics.js snippet, additional css and settings code not included
(...)
const scrollHandler = (state) => {
const lyricsP = $('#lyrics p');
if (state) { // enable auto scroll
lyricsP.attr('scroll', true);
animate = true;
timeHandler(remote.getGlobal('PlaybackAPI').data.time);
// reset scroll to proper place
} else { // disable auto scroll
lyricsP.removeAttr('scroll');
animate = false;
clearTimeout(animationTimer);
lyricsP.stop();
// stop scroll
}
};
// run once to set up
scrollHandler(Settings.get('scrollLyrics', true));
// triggered on settings toggle
Emitter.on('settings:set:scrollLyrics', (e, arg) => scrollHandler(arg));
(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment