New Pokéball Arriving in Pokémon Go – Gameranx 3) { var type = ‘event’; var eventName = ‘timing_complete’; fieldsArray = { event_category : ‘Scroll Depth’, name : action, event_label : label, value : timing, non_interaction: 1, send_to: ‘UA-7939758-5’ }; MonsterInsightsObject.sendEvent( type, eventName, fieldsArray ); } } function calculateMarks(docHeight) { return { ‘25%’ : parseInt(docHeight * 0.25, 10), ‘50%’ : parseInt(docHeight * 0.50, 10), ‘75%’ : parseInt(docHeight * 0.75, 10), /* Cushion to trigger 100% event in iOS */ ‘100%’: docHeight – 5 }; } function checkMarks(marks, scrollDistance, timing) { /* Check each active mark */ $.each(marks, function(key, val) { if ( $.inArray(key, cache) === -1 && scrollDistance >= val ) { sendEvent(‘Percentage’, key, scrollDistance, timing); cache.push(key); } }); } function rounded(scrollDistance) { /* Returns String */ return (Math.floor(scrollDistance/250) * 250).toString(); } function init() { bindScrollDepth(); } /* * Public Methods */ /* Reset Scroll Depth with the originally initialized options */ $.scrollDepth.reset = function() { cache = []; lastPixelDepth = 0; $window.off(‘scroll.scrollDepth’); bindScrollDepth(); }; /* Add DOM elements to be tracked */ $.scrollDepth.addElements = function(elems) { if (typeof elems == “undefined” || !$.isArray(elems)) { return; } $.merge(options.elements, elems); /* If scroll event has been unbound from window, rebind */ if (!scrollEventBound) { bindScrollDepth(); } }; /* Remove DOM elements currently tracked */ $.scrollDepth.removeElements = function(elems) { if (typeof elems == “undefined” || !$.isArray(elems)) { return; } $.each(elems, function(index, elem) { var inElementsArray = $.inArray(elem, options.elements); var inCacheArray = $.inArray(elem, cache); if (inElementsArray != -1) { options.elements.splice(inElementsArray, 1); } if (inCacheArray != -1) { cache.splice(inCacheArray, 1); } }); }; /* * Throttle function borrowed from: * Underscore.js 1.5.2 * http://underscorejs.org * (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Underscore may be freely distributed under the MIT license. */ function throttle(func, wait) { var context, args, result; var timeout = null; var previous = 0; var later = function() { previous = new Date; timeout = null; result = func.apply(context, args); }; return function() { var now = new Date; if…

Source

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>