Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // fix popup for mobile tablet
  2.     ajq('#evergage-tooltip-amb${message.id}').css("position", "absolute");
  3.    
  4.     var timeLimitSec = 6;
  5.     var expand = false;
  6.     var bottomCounter = 0;
  7.     var start;
  8.    
  9.     //function checks if the div has expanded
  10.     function checkExpand(){
  11.       if (ajq("#orderAreaWrap").css("display") != "none"){
  12.         console.log('Product Wrap is expanded');
  13.         expand = true;
  14.         clearInterval(listener);
  15.         start = performance.now();
  16.         //only listen after  seconds, that way the page is fully loaded
  17.         setTimeout(function(){
  18.            
  19.             console.log('start listening')
  20.             scroller();
  21.            
  22.         } , 3000);
  23.       }
  24.     }
  25.    
  26.      //listens ever 20 ms to see if the page has expanded.
  27.    var listener = setInterval(function(){
  28.        console.log('checking expanded');
  29.        checkExpand();}, 20);
  30.  
  31.     //scroll listener
  32.     function scroller(){
  33.       ajq(window).scroll(function(event){
  34.         var position = ajq(window).scrollTop();
  35.         var height = ajq(document).height();
  36.         var windowHeight = ajq(window).height();
  37.         var diff = height -windowHeight;
  38.         var diffTime  = performance.now() - start;
  39.        
  40.         //only fire off message if it gets to the bottom under the specified timeLimit and only fire off ONCE.
  41.         if (diff == position && expand===true && diffTime/1000<timeLimitSec && bottomCounter === 0){
  42.               console.log('Loaded');
  43.               _aaq.push(['trackAction', 'fireFastScroll']);
  44.              
  45.               bottomCounter = bottomCounter + 1;
  46.              }
  47.       });
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement