Asia A
China
| 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); | ||
| } | |||
| }); | |||
| }; |