Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
// 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;
});
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
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 ]);
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();
});
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, {});