Blame view

bower_components/Materialize/js/jquery.hammer.js 988 Bytes
74249687   Luigi Serra   Cross browser con...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  (function(factory) {
      if (typeof define === 'function' && define.amd) {
          define(['jquery', 'hammerjs'], factory);
      } else if (typeof exports === 'object') {
          factory(require('jquery'), require('hammerjs'));
      } else {
          factory(jQuery, Hammer);
      }
  }(function($, Hammer) {
      function hammerify(el, options) {
          var $el = $(el);
          if(!$el.data("hammer")) {
              $el.data("hammer", new Hammer($el[0], options));
          }
      }
  
      $.fn.hammer = function(options) {
          return this.each(function() {
              hammerify(this, options);
          });
      };
  
      // extend the emit method to also trigger jQuery events
      Hammer.Manager.prototype.emit = (function(originalEmit) {
          return function(type, data) {
              originalEmit.call(this, type, data);
              $(this.element).trigger({
                  type: type,
                  gesture: data
              });
          };
      })(Hammer.Manager.prototype.emit);
  }));