Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleHammer: function(ev) {
// disable browser scrolling
//ev.preventDefault();
switch(ev.type) {
case 'panright':
case 'panleft':
// stick to the finger
var pane_offset = -(100/this.pane_count) * this.current_pane;
var drag_offset = ((100/this.pane_width) * ev.deltaX) / this.pane_count;
// 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();
}
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(){
export class HammerConfig extends HammerGestureConfig {
overrides = {
pan: {
direction: 6
},
pinch: {
enable: false
},
rotate: {
enable: false
},
press: {
pointers: 1, time: 501, threshold: 15
},
swipe: {
pointers: 1, direction: Hammer.DIRECTION_LEFT, threshold: 20, velocity: 0.4
}
};
}
@NgModule({
declarations: [
AppComponent,
BottomBarComponent,
PrinterStatusComponent,
JobStatusComponent,
LayerProgressComponent,
InvalidConfigComponent,
NoConfigComponent,
PrintControlComponent,
NotificationComponent,
MainMenuComponent,
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;
}
}
};
import { PrinterService } from './printer.service';
import { URLSafePipe } from './url.pipe';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
import { NgxSpinnerModule } from 'ngx-spinner';
import * as Hammer from 'hammerjs';
import { RoundProgressModule } from 'angular-svg-round-progressbar';
export class MyHammerConfig extends HammerGestureConfig {
overrides = {
press: { pointers: 1, time: 501, threshold: 15 },
swipe: { pointers: 1, direction: Hammer.DIRECTION_LEFT, threshold: 20, velocity: 0.4 }
} as any;
}
export class HammerConfig extends HammerGestureConfig {
overrides = {
pan: {
direction: 6
},
pinch: {
enable: false
},
rotate: {
enable: false
},
press: {
pointers: 1, time: 501, threshold: 15
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;
}
});
},
onSwipe = e => {
if (e.direction === Hammer.DIRECTION_LEFT) this.props.onNext()
else if (e.direction === Hammer.DIRECTION_RIGHT) this.props.onPrevious()
}
const {
activeOffsetXStart,
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];