Created
March 11, 2016 16:09
-
-
Save BobbyAdamson/34c5ece1846c034d1e58 to your computer and use it in GitHub Desktop.
Revisions
-
Bobby Adamson created this gist
Mar 11, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ randomFlipping = function(){ // So we know what to flip var mediaItem = $('.xItem.xMedialayer.xContentImage, .xItem.xMedialayer.xContentVideo'); // So we know how many items there are var totalItemsWithMedia = $(mediaItem).length; // Want to run the function on a somewhat random interval setInterval(function(){ // Randomly finding an element to flip var itemNumberToFlip = Math.round(Math.random() * totalItemsWithMedia); var itemToFlip = $(mediaItem)[itemNumberToFlip]; // Flip the element $(itemToFlip).find('.xItemInner').addClass('xActive'); // Flip the element back in a few seconds setTimeout(function(){ $(itemToFlip).find('.xItemInner').removeClass('xActive'); }, (Math.random() * 6) + 6 * 1000); }, ((Math.random() * 6)) * 500); },