Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Last active June 14, 2018 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anasnakawa/5fe558296535017c91900f5e8d064ad4 to your computer and use it in GitHub Desktop.
Save anasnakawa/5fe558296535017c91900f5e8d064ad4 to your computer and use it in GitHub Desktop.
snippet when it will be added to the page, it will pause one or more tickers shortpoint elements
<script type="text/javascript">
(function() {
'use strict';
/**
* configurations
*/
var tickersClass = 'my-paused-ticker';
/**
* hook method to be executed as soon as shortpoint
* is available in the page
*/
function initHook() {
// exit on edit mode
if( window.shortPointInserter ) {
return;
}
setTimeout( pauseTickers, 500);
};
/**
* pause one or more tickers on the page
*/
function pauseTickers() {
var $ = shortpoint.$;
$( '.' + tickersClass ).each(function() {
clearInterval( $(this).data('shortpointTickers').timer );
})
}
// shortpoint not yet available in the page
// wait for shortpoint ready dom event
document.addEventListener( 'shortpoint-render-above-fold', initHook );
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment