/*! jquery-event-transmit v1.0.0 | (c) 2015, TomoyaOtsuka | MIT Licence */
(function($) {
  $.fn.eventTransmit = function(option) {
    var defaults = {
      runtime:  5000,
      category: "",
      action:   "",
      label:    ""
    };
    var setting = $.extend(defaults,option);

    var $window = $(window);
    var $target = $(this);
    var targetOffset;
    var targetHeight;
    var windowHeight;
    var view;

    var flag = true;
    var clearflag = false;
    var timer;



    $window.on('load pjax:load',function() {
      targetOffset = $target.offset().top;
      targetHeight = $target.height();
      windowHeight = $window.height();
      view = {
        'top':    targetOffset - windowHeight/2,
        'bottom': targetOffset + targetHeight - windowHeight/2
      };

      set();
    });



    function set() {
      $window.on('scroll',function() {
        var value = $(this).scrollTop();

        if (value > view.top && value < view.bottom && flag) {

          run();
          flag = false;
          clearflag = true;

        } else if (value < view.top || value > view.bottom) {

          if (clearflag) {
            clear();
            flag = true;
            clearflag = false;
          }
        }
      });
    }

    function run() {
      timer = window.setTimeout(function() { transmit(); }, setting.runtime);
    }

    function clear() {
      clearTimeout(timer);
    }

    function transmit() {
      ga('send', 'event', setting.category, setting.action, setting.label, {'nonInteraction':true});
      flag = false;
      clearflag = false;
    }


    return(this);
  };
})(jQuery);

@@ -150,30 +150,8 @@
 = %7B%0A
-      runtime:  5000,%0A
     
@@ -204,16 +204,88 @@
 l:    %22%22
+,%0A      position: %22default%22,%0A      runtime:  5000,%0A      debug:    false
 %0A    %7D;%0A
@@ -703,23 +703,210 @@
 ();%0A
-      view = %7B%0A
+%0A      if (setting.position == %22bottom%22) %7B%0A        view = %7B%0A          'top'   : targetOffset - windowHeight,%0A          'bottom': targetOffset + targetHeight%0A        %7D;%0A      %7D else %7B%0A        view = %7B%0A  
     
@@ -950,16 +950,18 @@
 ight/2,%0A
+  
         
@@ -1021,18 +1021,28 @@
 2%0A      
+  %7D;%0A      
 %7D
-;
 %0A%0A      
@@ -1640,61 +1640,241 @@
     
-clearTimeout(timer);%0A    %7D%0A%0A    function transmit() %7B
+if (setting.debug) %7B console.log('Event Transmit Clear'); %7D%0A      clearTimeout(timer);%0A    %7D%0A%0A    function transmit() %7B%0A      if (setting.debug) %7B console.log($target.attr('class'), setting.category, setting.action, setting.label); %7D
 %0A   

Add Setting "Position" Add Debug Mode