Plugin Directory

Changeset 1705922


Ignore:
Timestamp:
07/31/2017 08:46:44 PM (8 years ago)
Author:
firebrandllc
Message:

4.8 updates

Location:
wp-scroll-depth/trunk/js/jquery-scrolldepth
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • wp-scroll-depth/trunk/js/jquery-scrolldepth/bower.json

    r1390582 r1705922  
    22  "name": "scroll-depth",
    33  "main": "jquery.scrolldepth.js",
    4   "version": "0.9.0",
     4  "version": "1.0.0",
    55  "homepage": "http://scrolldepth.parsnip.io",
    66  "authors": [
     
    1818  "dependencies": {
    1919    "jquery" : ">=1.8"
    20   }, 
     20  },
    2121  "license": "MIT",
    2222  "ignore": [
  • wp-scroll-depth/trunk/js/jquery-scrolldepth/jquery.scrolldepth.js

    r1390582 r1705922  
    11/*!
    22 * @preserve
    3  * jquery.scrolldepth.js | v0.9
    4  * Copyright (c) 2015 Rob Flaherty (@robflaherty)
     3 * jquery.scrolldepth.js | v1.0
     4 * Copyright (c) 2016 Rob Flaherty (@robflaherty)
    55 * Licensed under the MIT and GPL licenses.
    66 */
    7 ;(function ( $, window, document, undefined ) {
    8 
    9   "use strict";
    10 
    11   var defaults = {
    12     minHeight: 0,
    13     elements: [],
    14     percentage: true,
    15     userTiming: true,
    16     pixelDepth: true,
    17     nonInteraction: true,
    18     gaGlobal: false,
    19     gtmOverride: false
    20   };
    21 
    22   var $window = $(window),
    23     cache = [],
    24     scrollEventBound = false,
    25     lastPixelDepth = 0,
    26     universalGA,
    27     classicGA,
    28     gaGlobal,
    29     standardEventHandler;
    30 
    31   /*
    32    * Plugin
    33    */
    34 
    35   $.scrollDepth = function(options) {
    36 
    37     var startTime = +new Date;
    38 
    39     options = $.extend({}, defaults, options);
    40 
    41     // Return early if document height is too small
    42     if ( $(document).height() < options.minHeight ) {
    43       return;
    44     }
     7
     8/* Universal module definition */
     9
     10(function(factory) {
     11  if (typeof define === 'function' && define.amd) {
     12    // AMD
     13    define(['jquery'], factory);
     14  } else if (typeof module === 'object' && module.exports) {
     15    // CommonJS
     16    module.exports = factory(require('jquery'));
     17  } else {
     18    // Browser globals
     19    factory(jQuery);
     20  }
     21}(function($) {
     22
     23/* Scroll Depth */
     24
     25    "use strict";
     26
     27    var defaults = {
     28      minHeight: 0,
     29      elements: [],
     30      percentage: true,
     31      userTiming: true,
     32      pixelDepth: true,
     33      nonInteraction: true,
     34      gaGlobal: false,
     35      gtmOverride: false,
     36      trackerName: false,
     37      dataLayer: 'dataLayer'
     38    };
     39
     40    var $window = $(window),
     41      cache = [],
     42      scrollEventBound = false,
     43      lastPixelDepth = 0,
     44      universalGA,
     45      classicGA,
     46      gaGlobal,
     47      standardEventHandler;
    4548
    4649    /*
    47      * Determine which version of GA is being used
    48      * "ga", "__gaTracker", _gaq", and "dataLayer" are the possible globals
     50     * Plugin
    4951     */
    5052
    51     if (options.gaGlobal) {
    52       universalGA = true;
    53       gaGlobal = options.gaGlobal;
    54     } else if (typeof ga === "function") {
    55       universalGA = true;
    56       gaGlobal = 'ga';
    57     } else if (typeof __gaTracker === "function") {
    58       universalGA = true;
    59       gaGlobal = '__gaTracker';
    60     }
    61 
    62     if (typeof _gaq !== "undefined" && typeof _gaq.push === "function") {
    63       classicGA = true;
    64     }
    65 
    66     if (typeof options.eventHandler === "function") {
    67       standardEventHandler = options.eventHandler;
    68     } else if (typeof dataLayer !== "undefined" && typeof dataLayer.push === "function" && !options.gtmOverride) {
    69 
    70       standardEventHandler = function(data) {
    71         dataLayer.push(data);
    72       };
    73     }
    74 
    75     /*
    76      * Functions
    77      */
    78 
    79     function sendEvent(action, label, scrollDistance, timing) {
    80 
    81       if (standardEventHandler) {
    82 
    83         standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': options.nonInteraction});
    84 
    85         if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
    86           lastPixelDepth = scrollDistance;
    87           standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': 'Pixel Depth', 'eventLabel': rounded(scrollDistance), 'eventValue': 1, 'eventNonInteraction': options.nonInteraction});
    88         }
    89 
    90         if (options.userTiming && arguments.length > 3) {
    91           standardEventHandler({'event': 'ScrollTiming', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventTiming': timing});
    92         }
    93 
    94       } else {
    95 
    96         if (universalGA) {
    97 
    98           window[gaGlobal]('send', 'event', 'Scroll Depth', action, label, 1, {'nonInteraction': options.nonInteraction});
     53    $.scrollDepth = function(options) {
     54
     55      var startTime = +new Date;
     56
     57      options = $.extend({}, defaults, options);
     58
     59      // Return early if document height is too small
     60      if ( $(document).height() < options.minHeight ) {
     61        return;
     62      }
     63
     64      /*
     65       * Determine which version of GA is being used
     66       * "ga", "__gaTracker", _gaq", and "dataLayer" are the possible globals
     67       */
     68
     69      if (options.gaGlobal) {
     70        universalGA = true;
     71        gaGlobal = options.gaGlobal;
     72      } else if (typeof ga === "function") {
     73        universalGA = true;
     74        gaGlobal = 'ga';
     75      } else if (typeof __gaTracker === "function") {
     76        universalGA = true;
     77        gaGlobal = '__gaTracker';
     78      }
     79
     80      if (typeof _gaq !== "undefined" && typeof _gaq.push === "function") {
     81        classicGA = true;
     82      }
     83
     84      if (typeof options.eventHandler === "function") {
     85        standardEventHandler = options.eventHandler;
     86      } else if (typeof window[options.dataLayer] !== "undefined" && typeof window[options.dataLayer].push === "function" && !options.gtmOverride) {
     87
     88        standardEventHandler = function(data) {
     89          window[options.dataLayer].push(data);
     90        };
     91      }
     92
     93      /*
     94       * Functions
     95       */
     96
     97      function sendEvent(action, label, scrollDistance, timing) {
     98
     99        var command = options.trackerName ? (options.trackerName + '.send') : 'send';
     100
     101        if (standardEventHandler) {
     102
     103          standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': options.nonInteraction});
    99104
    100105          if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
    101106            lastPixelDepth = scrollDistance;
    102             window[gaGlobal]('send', 'event', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, {'nonInteraction': options.nonInteraction});
     107            standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': 'Pixel Depth', 'eventLabel': rounded(scrollDistance), 'eventValue': 1, 'eventNonInteraction': options.nonInteraction});
    103108          }
    104109
    105110          if (options.userTiming && arguments.length > 3) {
    106             window[gaGlobal]('send', 'timing', 'Scroll Depth', action, timing, label);
     111            standardEventHandler({'event': 'ScrollTiming', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventTiming': timing});
     112          }
     113
     114        } else {
     115
     116          if (universalGA) {
     117
     118            window[gaGlobal](command, 'event', 'Scroll Depth', action, label, 1, {'nonInteraction': options.nonInteraction});
     119
     120            if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
     121              lastPixelDepth = scrollDistance;
     122              window[gaGlobal](command, 'event', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, {'nonInteraction': options.nonInteraction});
     123            }
     124
     125            if (options.userTiming && arguments.length > 3) {
     126              window[gaGlobal](command, 'timing', 'Scroll Depth', action, timing, label);
     127            }
     128
     129          }
     130
     131          if (classicGA) {
     132
     133            _gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, options.nonInteraction]);
     134
     135            if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
     136              lastPixelDepth = scrollDistance;
     137              _gaq.push(['_trackEvent', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, options.nonInteraction]);
     138            }
     139
     140            if (options.userTiming && arguments.length > 3) {
     141              _gaq.push(['_trackTiming', 'Scroll Depth', action, timing, label, 100]);
     142            }
     143
    107144          }
    108145
    109146        }
    110147
    111         if (classicGA) {
    112 
    113           _gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, options.nonInteraction]);
    114 
    115           if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
    116             lastPixelDepth = scrollDistance;
    117             _gaq.push(['_trackEvent', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, options.nonInteraction]);
    118           }
    119 
    120           if (options.userTiming && arguments.length > 3) {
    121             _gaq.push(['_trackTiming', 'Scroll Depth', action, timing, label, 100]);
    122           }
    123 
    124         }
    125 
    126       }
    127 
    128     }
    129 
    130     function calculateMarks(docHeight) {
    131       return {
    132         '25%' : parseInt(docHeight * 0.25, 10),
    133         '50%' : parseInt(docHeight * 0.50, 10),
    134         '75%' : parseInt(docHeight * 0.75, 10),
    135         // Cushion to trigger 100% event in iOS
    136         '100%': docHeight - 5
     148      }
     149
     150      function calculateMarks(docHeight) {
     151        return {
     152          '25%' : parseInt(docHeight * 0.25, 10),
     153          '50%' : parseInt(docHeight * 0.50, 10),
     154          '75%' : parseInt(docHeight * 0.75, 10),
     155          // Cushion to trigger 100% event in iOS
     156          '100%': docHeight - 5
     157        };
     158      }
     159
     160      function checkMarks(marks, scrollDistance, timing) {
     161        // Check each active mark
     162        $.each(marks, function(key, val) {
     163          if ( $.inArray(key, cache) === -1 && scrollDistance >= val ) {
     164            sendEvent('Percentage', key, scrollDistance, timing);
     165            cache.push(key);
     166          }
     167        });
     168      }
     169
     170      function checkElements(elements, scrollDistance, timing) {
     171        $.each(elements, function(index, elem) {
     172          if ( $.inArray(elem, cache) === -1 && $(elem).length ) {
     173            if ( scrollDistance >= $(elem).offset().top ) {
     174              sendEvent('Elements', elem, scrollDistance, timing);
     175              cache.push(elem);
     176            }
     177          }
     178        });
     179      }
     180
     181      function rounded(scrollDistance) {
     182        // Returns String
     183        return (Math.floor(scrollDistance/250) * 250).toString();
     184      }
     185
     186      function init() {
     187        bindScrollDepth();
     188      }
     189
     190      /*
     191       * Public Methods
     192       */
     193
     194      // Reset Scroll Depth with the originally initialized options
     195      $.scrollDepth.reset = function() {
     196        cache = [];
     197        lastPixelDepth = 0;
     198        $window.off('scroll.scrollDepth');
     199        bindScrollDepth();
    137200      };
    138     }
    139 
    140     function checkMarks(marks, scrollDistance, timing) {
    141       // Check each active mark
    142       $.each(marks, function(key, val) {
    143         if ( $.inArray(key, cache) === -1 && scrollDistance >= val ) {
    144           sendEvent('Percentage', key, scrollDistance, timing);
    145           cache.push(key);
    146         }
    147       });
    148     }
    149 
    150     function checkElements(elements, scrollDistance, timing) {
    151       $.each(elements, function(index, elem) {
    152         if ( $.inArray(elem, cache) === -1 && $(elem).length ) {
    153           if ( scrollDistance >= $(elem).offset().top ) {
    154             sendEvent('Elements', elem, scrollDistance, timing);
    155             cache.push(elem);
    156           }
    157         }
    158       });
    159     }
    160 
    161     function rounded(scrollDistance) {
    162       // Returns String
    163       return (Math.floor(scrollDistance/250) * 250).toString();
    164     }
    165 
    166     function init() {
    167       bindScrollDepth();
    168     }
    169 
    170     /*
    171      * Public Methods
    172      */
    173 
    174     // Reset Scroll Depth with the originally initialized options
    175     $.scrollDepth.reset = function() {
    176       cache = [];
    177       lastPixelDepth = 0;
    178       $window.off('scroll.scrollDepth');
    179       bindScrollDepth();
    180     };
    181 
    182     // Add DOM elements to be tracked
    183     $.scrollDepth.addElements = function(elems) {
    184 
    185       if (typeof elems == "undefined" || !$.isArray(elems)) {
    186         return;
    187       }
    188 
    189       $.merge(options.elements, elems);
    190 
    191       // If scroll event has been unbound from window, rebind
    192       if (!scrollEventBound) {
    193         bindScrollDepth();
    194       }
    195 
    196     };
    197 
    198     // Remove DOM elements currently tracked
    199     $.scrollDepth.removeElements = function(elems) {
    200 
    201       if (typeof elems == "undefined" || !$.isArray(elems)) {
    202         return;
    203       }
    204 
    205       $.each(elems, function(index, elem) {
    206 
    207         var inElementsArray = $.inArray(elem, options.elements);
    208         var inCacheArray = $.inArray(elem, cache);
    209 
    210         if (inElementsArray != -1) {
    211           options.elements.splice(inElementsArray, 1);
    212         }
    213 
    214         if (inCacheArray != -1) {
    215           cache.splice(inCacheArray, 1);
    216         }
    217 
    218       });
    219 
    220     };
    221 
    222     /*
    223      * Throttle function borrowed from:
    224      * Underscore.js 1.5.2
    225      * http://underscorejs.org
    226      * (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
    227      * Underscore may be freely distributed under the MIT license.
    228      */
    229 
    230     function throttle(func, wait) {
    231       var context, args, result;
    232       var timeout = null;
    233       var previous = 0;
    234       var later = function() {
    235         previous = new Date;
    236         timeout = null;
    237         result = func.apply(context, args);
    238       };
    239       return function() {
    240         var now = new Date;
    241         if (!previous) previous = now;
    242         var remaining = wait - (now - previous);
    243         context = this;
    244         args = arguments;
    245         if (remaining <= 0) {
    246           clearTimeout(timeout);
    247           timeout = null;
    248           previous = now;
    249           result = func.apply(context, args);
    250         } else if (!timeout) {
    251           timeout = setTimeout(later, remaining);
    252         }
    253         return result;
    254       };
    255     }
    256 
    257     /*
    258      * Scroll Event
    259      */
    260 
    261     function bindScrollDepth() {
    262 
    263       scrollEventBound = true;
    264 
    265       $window.on('scroll.scrollDepth', throttle(function() {
    266         /*
    267          * We calculate document and window height on each scroll event to
    268          * account for dynamic DOM changes.
    269          */
    270 
    271         var docHeight = $(document).height(),
    272           winHeight = window.innerHeight ? window.innerHeight : $window.height(),
    273           scrollDistance = $window.scrollTop() + winHeight,
    274 
    275           // Recalculate percentage marks
    276           marks = calculateMarks(docHeight),
    277 
    278           // Timing
    279           timing = +new Date - startTime;
    280 
    281         // If all marks already hit, unbind scroll event
    282         if (cache.length >= options.elements.length + (options.percentage ? 4:0)) {
    283           $window.off('scroll.scrollDepth');
    284           scrollEventBound = false;
     201
     202      // Add DOM elements to be tracked
     203      $.scrollDepth.addElements = function(elems) {
     204
     205        if (typeof elems == "undefined" || !$.isArray(elems)) {
    285206          return;
    286207        }
    287208
    288         // Check specified DOM elements
    289         if (options.elements) {
    290           checkElements(options.elements, scrollDistance, timing);
     209        $.merge(options.elements, elems);
     210
     211        // If scroll event has been unbound from window, rebind
     212        if (!scrollEventBound) {
     213          bindScrollDepth();
    291214        }
    292215
    293         // Check standard marks
    294         if (options.percentage) {
    295           checkMarks(marks, scrollDistance, timing);
     216      };
     217
     218      // Remove DOM elements currently tracked
     219      $.scrollDepth.removeElements = function(elems) {
     220
     221        if (typeof elems == "undefined" || !$.isArray(elems)) {
     222          return;
    296223        }
    297       }, 500));
    298 
    299     }
    300 
    301     init();
    302 
    303   };
    304 
    305 })( jQuery, window, document );
     224
     225        $.each(elems, function(index, elem) {
     226
     227          var inElementsArray = $.inArray(elem, options.elements);
     228          var inCacheArray = $.inArray(elem, cache);
     229
     230          if (inElementsArray != -1) {
     231            options.elements.splice(inElementsArray, 1);
     232          }
     233
     234          if (inCacheArray != -1) {
     235            cache.splice(inCacheArray, 1);
     236          }
     237
     238        });
     239
     240      };
     241
     242      /*
     243       * Throttle function borrowed from:
     244       * Underscore.js 1.5.2
     245       * http://underscorejs.org
     246       * (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
     247       * Underscore may be freely distributed under the MIT license.
     248       */
     249
     250      function throttle(func, wait) {
     251        var context, args, result;
     252        var timeout = null;
     253        var previous = 0;
     254        var later = function() {
     255          previous = new Date;
     256          timeout = null;
     257          result = func.apply(context, args);
     258        };
     259        return function() {
     260          var now = new Date;
     261          if (!previous) previous = now;
     262          var remaining = wait - (now - previous);
     263          context = this;
     264          args = arguments;
     265          if (remaining <= 0) {
     266            clearTimeout(timeout);
     267            timeout = null;
     268            previous = now;
     269            result = func.apply(context, args);
     270          } else if (!timeout) {
     271            timeout = setTimeout(later, remaining);
     272          }
     273          return result;
     274        };
     275      }
     276
     277      /*
     278       * Scroll Event
     279       */
     280
     281      function bindScrollDepth() {
     282
     283        scrollEventBound = true;
     284
     285        $window.on('scroll.scrollDepth', throttle(function() {
     286          /*
     287           * We calculate document and window height on each scroll event to
     288           * account for dynamic DOM changes.
     289           */
     290
     291          var docHeight = $(document).height(),
     292            winHeight = window.innerHeight ? window.innerHeight : $window.height(),
     293            scrollDistance = $window.scrollTop() + winHeight,
     294
     295            // Recalculate percentage marks
     296            marks = calculateMarks(docHeight),
     297
     298            // Timing
     299            timing = +new Date - startTime;
     300
     301          // If all marks already hit, unbind scroll event
     302          if (cache.length >= options.elements.length + (options.percentage ? 4:0)) {
     303            $window.off('scroll.scrollDepth');
     304            scrollEventBound = false;
     305            return;
     306          }
     307
     308          // Check specified DOM elements
     309          if (options.elements) {
     310            checkElements(options.elements, scrollDistance, timing);
     311          }
     312
     313          // Check standard marks
     314          if (options.percentage) {
     315            checkMarks(marks, scrollDistance, timing);
     316          }
     317        }, 500));
     318
     319      }
     320
     321      init();
     322
     323    };
     324
     325    // UMD export
     326    return $.scrollDepth;
     327
     328}));
  • wp-scroll-depth/trunk/js/jquery-scrolldepth/jquery.scrolldepth.min.js

    r1390582 r1705922  
    11/*!
    22 * @preserve
    3  * jquery.scrolldepth.js | v0.9
    4  * Copyright (c) 2015 Rob Flaherty (@robflaherty)
     3 * jquery.scrolldepth.js | v1.0
     4 * Copyright (c) 2016 Rob Flaherty (@robflaherty)
    55 * Licensed under the MIT and GPL licenses.
    66 */
    7 !function(e,n,t){"use strict";var r,o,i,l,a={minHeight:0,elements:[],percentage:!0,userTiming:!0,pixelDepth:!0,nonInteraction:!0,gaGlobal:!1,gtmOverride:!1},c=e(n),u=[],p=!1,s=0;e.scrollDepth=function(h){function g(e,t,a,c){l?(l({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:e,eventLabel:t,eventValue:1,eventNonInteraction:h.nonInteraction}),h.pixelDepth&&arguments.length>2&&a>s&&(s=a,l({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:D(a),eventValue:1,eventNonInteraction:h.nonInteraction})),h.userTiming&&arguments.length>3&&l({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:e,eventLabel:t,eventTiming:c})):(r&&(n[i]("send","event","Scroll Depth",e,t,1,{nonInteraction:h.nonInteraction}),h.pixelDepth&&arguments.length>2&&a>s&&(s=a,n[i]("send","event","Scroll Depth","Pixel Depth",D(a),1,{nonInteraction:h.nonInteraction})),h.userTiming&&arguments.length>3&&n[i]("send","timing","Scroll Depth",e,c,t)),o&&(_gaq.push(["_trackEvent","Scroll Depth",e,t,1,h.nonInteraction]),h.pixelDepth&&arguments.length>2&&a>s&&(s=a,_gaq.push(["_trackEvent","Scroll Depth","Pixel Depth",D(a),1,h.nonInteraction])),h.userTiming&&arguments.length>3&&_gaq.push(["_trackTiming","Scroll Depth",e,c,t,100])))}function f(e){return{"25%":parseInt(.25*e,10),"50%":parseInt(.5*e,10),"75%":parseInt(.75*e,10),"100%":e-5}}function v(n,t,r){e.each(n,function(n,o){-1===e.inArray(n,u)&&t>=o&&(g("Percentage",n,t,r),u.push(n))})}function m(n,t,r){e.each(n,function(n,o){-1===e.inArray(o,u)&&e(o).length&&t>=e(o).offset().top&&(g("Elements",o,t,r),u.push(o))})}function D(e){return(250*Math.floor(e/250)).toString()}function d(){I()}function y(e,n){var t,r,o,i=null,l=0,a=function(){l=new Date,i=null,o=e.apply(t,r)};return function(){var c=new Date;l||(l=c);var u=n-(c-l);return t=this,r=arguments,0>=u?(clearTimeout(i),i=null,l=c,o=e.apply(t,r)):i||(i=setTimeout(a,u)),o}}function I(){p=!0,c.on("scroll.scrollDepth",y(function(){var r=e(t).height(),o=n.innerHeight?n.innerHeight:c.height(),i=c.scrollTop()+o,l=f(r),a=+new Date-S;return u.length>=h.elements.length+(h.percentage?4:0)?(c.off("scroll.scrollDepth"),void(p=!1)):(h.elements&&m(h.elements,i,a),void(h.percentage&&v(l,i,a)))},500))}var S=+new Date;h=e.extend({},a,h),e(t).height()<h.minHeight||(h.gaGlobal?(r=!0,i=h.gaGlobal):"function"==typeof ga?(r=!0,i="ga"):"function"==typeof __gaTracker&&(r=!0,i="__gaTracker"),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(o=!0),"function"==typeof h.eventHandler?l=h.eventHandler:"undefined"==typeof dataLayer||"function"!=typeof dataLayer.push||h.gtmOverride||(l=function(e){dataLayer.push(e)}),e.scrollDepth.reset=function(){u=[],s=0,c.off("scroll.scrollDepth"),I()},e.scrollDepth.addElements=function(n){"undefined"!=typeof n&&e.isArray(n)&&(e.merge(h.elements,n),p||I())},e.scrollDepth.removeElements=function(n){"undefined"!=typeof n&&e.isArray(n)&&e.each(n,function(n,t){var r=e.inArray(t,h.elements),o=e.inArray(t,u);-1!=r&&h.elements.splice(r,1),-1!=o&&u.splice(o,1)})},d())}}(jQuery,window,document);
     7!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";var n,t,r,o,i={minHeight:0,elements:[],percentage:!0,userTiming:!0,pixelDepth:!0,nonInteraction:!0,gaGlobal:!1,gtmOverride:!1,trackerName:!1,dataLayer:"dataLayer"},a=e(window),l=[],c=!1,u=0;return e.scrollDepth=function(p){function s(e,i,a,l){var c=p.trackerName?p.trackerName+".send":"send";o?(o({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:e,eventLabel:i,eventValue:1,eventNonInteraction:p.nonInteraction}),p.pixelDepth&&arguments.length>2&&a>u&&(u=a,o({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:d(a),eventValue:1,eventNonInteraction:p.nonInteraction})),p.userTiming&&arguments.length>3&&o({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:e,eventLabel:i,eventTiming:l})):(n&&(window[r](c,"event","Scroll Depth",e,i,1,{nonInteraction:p.nonInteraction}),p.pixelDepth&&arguments.length>2&&a>u&&(u=a,window[r](c,"event","Scroll Depth","Pixel Depth",d(a),1,{nonInteraction:p.nonInteraction})),p.userTiming&&arguments.length>3&&window[r](c,"timing","Scroll Depth",e,l,i)),t&&(_gaq.push(["_trackEvent","Scroll Depth",e,i,1,p.nonInteraction]),p.pixelDepth&&arguments.length>2&&a>u&&(u=a,_gaq.push(["_trackEvent","Scroll Depth","Pixel Depth",d(a),1,p.nonInteraction])),p.userTiming&&arguments.length>3&&_gaq.push(["_trackTiming","Scroll Depth",e,l,i,100])))}function h(e){return{"25%":parseInt(.25*e,10),"50%":parseInt(.5*e,10),"75%":parseInt(.75*e,10),"100%":e-5}}function g(n,t,r){e.each(n,function(n,o){-1===e.inArray(n,l)&&t>=o&&(s("Percentage",n,t,r),l.push(n))})}function f(n,t,r){e.each(n,function(n,o){-1===e.inArray(o,l)&&e(o).length&&t>=e(o).offset().top&&(s("Elements",o,t,r),l.push(o))})}function d(e){return(250*Math.floor(e/250)).toString()}function m(){y()}function v(e,n){var t,r,o,i=null,a=0,l=function(){a=new Date,i=null,o=e.apply(t,r)};return function(){var c=new Date;a||(a=c);var u=n-(c-a);return t=this,r=arguments,0>=u?(clearTimeout(i),i=null,a=c,o=e.apply(t,r)):i||(i=setTimeout(l,u)),o}}function y(){c=!0,a.on("scroll.scrollDepth",v(function(){var n=e(document).height(),t=window.innerHeight?window.innerHeight:a.height(),r=a.scrollTop()+t,o=h(n),i=+new Date-D;return l.length>=p.elements.length+(p.percentage?4:0)?(a.off("scroll.scrollDepth"),void(c=!1)):(p.elements&&f(p.elements,r,i),void(p.percentage&&g(o,r,i)))},500))}var D=+new Date;p=e.extend({},i,p),e(document).height()<p.minHeight||(p.gaGlobal?(n=!0,r=p.gaGlobal):"function"==typeof ga?(n=!0,r="ga"):"function"==typeof __gaTracker&&(n=!0,r="__gaTracker"),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(t=!0),"function"==typeof p.eventHandler?o=p.eventHandler:"undefined"==typeof window[p.dataLayer]||"function"!=typeof window[p.dataLayer].push||p.gtmOverride||(o=function(e){window[p.dataLayer].push(e)}),e.scrollDepth.reset=function(){l=[],u=0,a.off("scroll.scrollDepth"),y()},e.scrollDepth.addElements=function(n){"undefined"!=typeof n&&e.isArray(n)&&(e.merge(p.elements,n),c||y())},e.scrollDepth.removeElements=function(n){"undefined"!=typeof n&&e.isArray(n)&&e.each(n,function(n,t){var r=e.inArray(t,p.elements),o=e.inArray(t,l);-1!=r&&p.elements.splice(r,1),-1!=o&&l.splice(o,1)})},m())},e.scrollDepth});
  • wp-scroll-depth/trunk/js/jquery-scrolldepth/readme.md

    r1390582 r1705922  
    33
    44**[All information is available on the Project Page](http://projects.parsnip.io/scroll-depth/)**
     5
     6## Forks
     7* There's a [WordPress plugin](https://wordpress.org/plugins/wp-scroll-depth/) maintained by Lon Koenig.
     8* There's a [non-jQuery fork](https://github.com/leighmcculloch/gascrolldepth.js) maintained by @leighmcculloch.
    59
    610## Contributing
     
    1418
    1519## Changelog
     201.0 (12/8/16): Added support for customer tracker name and custom dataLayer name.
     21
     220.9.1 (4/28/16): Added support for Universal Module Definition (UMD).
    1623
    17240.9 (11/19/15): Removed Baseline event. Added methods to add elements, remove elements, and reset the current scroll tracking state.
Note: See TracChangeset for help on using the changeset viewer.