Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// slow down at the first and last pane
if((this.current_pane == 0 && ev.direction == Hammer.DIRECTION_RIGHT) ||
(this.current_pane == this.pane_count-1 && ev.direction == Hammer.DIRECTION_LEFT)) {
drag_offset *= .4;
}
this.setContainerOffset(drag_offset + pane_offset);
break;
case 'panend':
case 'pancancel':
// Left & Right
// more then 1/3 moved, navigate
if(Math.abs(ev.deltaX) > this.pane_width/3) {
if(ev.direction == Hammer.DIRECTION_RIGHT) {
this.prevSlide();
} else {
this.nextSlide();
}
}
else {
this.showPane(this.current_pane, true);
}
break;
case 'swipeleft':
this.nextSlide();
break;
case 'swiperight':
it('should set direction to "right" when swiping right', function() {
simulateSwipeGestureMoves(hammerInstance, { deltaX: 0 }, { deltaX: 2 });
CustomSwipeGesture.handler(endEvent, hammerInstance);
expect(endEvent.direction).toBe(Hammer.DIRECTION_RIGHT);
});
it('should set direction to "up" when swiping up', function() {
this.carouselElm.nativeElement.addEventListener('transitionstart', function (e) {
var elm = { carousel: vm.carousel, event: e };
if (e.propertyName === "transform") {
_this.onTransitionStart.emit(elm);
if (e.direction === Hammer.DIRECTION_LEFT) {
vm.onSlideNextTransitionStart.emit(elm);
}
else if (e.direction === Hammer.DIRECTION_RIGHT) {
vm.onSlidePrevTransitionStart.emit(elm);
}
}
});
window.addEventListener("resize", function () {
this.carouselElm.nativeElement.addEventListener('transitionstart', (e : any) =>{
let elm = {carousel:vm.carousel,event:e};
if(e.propertyName === "transform"){
this.onTransitionStart.emit(elm);
if(e.direction === Hammer.DIRECTION_LEFT){
vm.onSlideNextTransitionStart.emit(elm);
}
else if(e.direction === Hammer.DIRECTION_RIGHT){
vm.onSlidePrevTransitionStart.emit(elm);
}
}
});
window.addEventListener("resize", function(){
function getDirection() {
var start = moves[0];
var end = moves[moves.length - 1];
var deltaX = Math.abs(end.deltaX - start.deltaX);
var deltaY = Math.abs(end.deltaY - start.deltaY);
if (deltaX >= deltaY) {
return start.deltaX > end.deltaX ? Hammer.DIRECTION_LEFT : Hammer.DIRECTION_RIGHT;
}
return start.deltaY > end.deltaY ? Hammer.DIRECTION_UP : Hammer.DIRECTION_DOWN;
}
onSwipe = e => {
if (e.direction === Hammer.DIRECTION_LEFT) this.props.onNext()
else if (e.direction === Hammer.DIRECTION_RIGHT) this.props.onPrevious()
}
onSwipe = (e) => {
switch (e.direction) {
case Hammer.DIRECTION_LEFT: {
const button = document.querySelector('[data-react-toolbox=calendar] button#right');
if (button) {
button.click();
}
break;
}
case Hammer.DIRECTION_RIGHT: {
const button = document.querySelector('[data-react-toolbox=calendar] button#left');
if (button) {
button.click();
}
break;
}
}
};
hljs.highlightBlock(block);
});
sr.reveal('.article', {viewFactor: 0.000001});
$('html').removeClass('sr');
const iv = new ImageGallery('.article');
const stage = document.getElementById('content-model');
const mc = new Hammer.Manager(stage);
const SwipeLeft = new Hammer.Swipe({
event: 'swipeleft',
direction: Hammer.DIRECTION_LEFT,
});
const SwipeRight = new Hammer.Swipe({
event: 'swiperight',
direction: Hammer.DIRECTION_RIGHT,
});
const Tap = new Hammer.Tap();
mc.add(SwipeLeft);
mc.add(SwipeRight);
mc.add(Tap);
$('.article img').click((e) => {
const index = iv.images.indexOf(e.target.src);
iv.changeImage(index);
$('.model').addClass('show animated fadeIn');
setTimeout(() => {
$('.model').removeClass('animated fadeIn');
}, 300);
$('body').addClass('model-open');
});
activeOffsetXEnd,
activeOffsetYStart,
activeOffsetYEnd,
minDist,
} = config;
let directions = [];
let horizontalDirections = [];
if (!isnan(minDist)) {
return Hammer.DIRECTION_ALL;
}
if (!isnan(activeOffsetXStart))
horizontalDirections.push(Hammer.DIRECTION_LEFT);
if (!isnan(activeOffsetXEnd))
horizontalDirections.push(Hammer.DIRECTION_RIGHT);
if (horizontalDirections.length === 2)
horizontalDirections = [Hammer.DIRECTION_HORIZONTAL];
directions = directions.concat(horizontalDirections);
let verticalDirections = [];
if (!isnan(activeOffsetYStart))
verticalDirections.push(Hammer.DIRECTION_UP);
if (!isnan(activeOffsetYEnd))
verticalDirections.push(Hammer.DIRECTION_DOWN);
if (verticalDirections.length === 2)
verticalDirections = [Hammer.DIRECTION_VERTICAL];
directions = directions.concat(verticalDirections);
mc.on("swipe", event => {
if (event.pointerType === "mouse") {
return;
}
switch (event.direction) {
case Hammer.DIRECTION_LEFT:
display.goNext();
return;
case Hammer.DIRECTION_RIGHT:
display.goPrev();
return;
}
});
},