How to use the hammerjs.TouchInput function in hammerjs

To help you get started, we’ve selected a few hammerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github naver / egjs-axes / test / unit / HammerInput.spec.js View on Github external
it("should check convertHammerInputType when supporting touch", () => {
      // Given
      const MockHammerInput = HammerInputInjector({
        "../const": {
          SUPPORT_TOUCH : true
        }
      }).HammerInput;
      
			// When
      let inputType = [ "touch", "mouse" ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.equal(Hammer.TouchInput);

      // When
      inputType = [ "touch" ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.equal(Hammer.TouchInput);

      // When
      inputType = [ "mouse" ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.equal(Hammer.MouseInput);

      // When
      inputType = [ ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.null;
    });
github naver / egjs-axes / test / unit / HammerInput.spec.js View on Github external
// Given
      const MockHammerInput = HammerInputInjector({
        "../const": {
          SUPPORT_TOUCH : true
        }
      }).HammerInput;
      
			// When
      let inputType = [ "touch", "mouse" ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.equal(Hammer.TouchInput);

      // When
      inputType = [ "touch" ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.equal(Hammer.TouchInput);

      // When
      inputType = [ "mouse" ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.equal(Hammer.MouseInput);

      // When
      inputType = [ ];
      // Then
      expect(MockHammerInput.convertHammerInputType(inputType)).to.be.null;
    });
github dcos / dcos-website / src / scripts / main.js View on Github external
nextTimeout.cancel();
  })

  slider.on('mouseleave', function(){
    nextTimeout.resume();
  })

  // Enable touch for Wallop
  Hammer(wallopEl, {
    inputClass: Hammer.TouchInput
  }).on('swipeleft', function() {
    slider.next();
  });

  Hammer(wallopEl, {
    inputClass: Hammer.TouchInput
  }).on('swiperight', function() {
    slider.previous();
  });

  for (var i = 0; i < navItems.length; i++) {
    navItems[i].addEventListener('click', function(e){
      e.preventDefault();
      slider.goTo(e.target.dataset.target);
      nextTimeout.resume();
    });

  }
}

/****************
  Clickable headers
github bpmn-io / diagram-js / lib / features / touch / TouchInteractionEvents.js View on Github external
forEach(mouseEvents, function(e) {
        domEvent.unbind(node, e, stopEvent, true);
      });
    }, 500);
  }

  domEvent.bind(node, 'touchstart', stopMouse, true);
  domEvent.bind(node, 'touchend', allowMouse, true);
  domEvent.bind(node, 'touchcancel', allowMouse, true);

  // A touch event recognizer that handles
  // touch events only (we know, we can already handle
  // mouse events out of the box)

  var recognizer = new Hammer.Manager(node, {
    inputClass: Hammer.TouchInput,
    recognizers: []
  });


  var tap = new Hammer.Tap();
  var pan = new Hammer.Pan({ threshold: 10 });
  var press = new Hammer.Press();
  var pinch = new Hammer.Pinch();

  var doubleTap = new Hammer.Tap({ event: 'doubletap', taps: 2 });

  pinch.requireFailure(pan);
  pinch.requireFailure(press);

  recognizer.add([ pan, press, pinch, doubleTap, tap ]);
github dcos / dcos-website / src / scripts / main.js View on Github external
nextTimeout.resume();
    document.querySelector('.hero-nav--item.active').classList.remove('active');
    navItems[e.detail.currentItemIndex].classList.add('active');
  });

  slider.on('mouseenter', function(){
    nextTimeout.cancel();
  })

  slider.on('mouseleave', function(){
    nextTimeout.resume();
  })

  // Enable touch for Wallop
  Hammer(wallopEl, {
    inputClass: Hammer.TouchInput
  }).on('swipeleft', function() {
    slider.next();
  });

  Hammer(wallopEl, {
    inputClass: Hammer.TouchInput
  }).on('swiperight', function() {
    slider.previous();
  });

  for (var i = 0; i < navItems.length; i++) {
    navItems[i].addEventListener('click', function(e){
      e.preventDefault();
      slider.goTo(e.target.dataset.target);
      nextTimeout.resume();
    });
github flowhub / the-graph / the-graph / hammer.js View on Github external
function TouchMouseInput() {
    Hammer.Input.apply(this, arguments);

    var handler = this.handler.bind(this);
    this.touch = new Hammer.TouchInput(this.manager, handler);
    this.mouse = new MouseInput(this.manager, handler);

    this.primaryTouch = null;
    this.lastTouches = [];
}
Hammer.inherit(TouchMouseInput, Hammer.TouchMouseInput, {});