Last active
June 14, 2018 12:13
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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