Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switch (element[0].nodeName) {
case 'rect':
x = 'x';
y = 'y';
break;
case 'circle':
x = 'cx';
y = 'cy';
break;
}
// Events
hammerSurface = new Hammer(markingSurface.svg);
hammerElement = new Hammer.Manager(element[0]);
hammerElement.add(new Hammer.Press({ time: 5 }));
hammerElement.add(new Hammer.Pan({ direction: Hammer.DIRECTION_ALL }));
hammerElement.on('press', startDrag);
// Methods
function getPoint(event) {
event = event.srcEvent || event;
return toolUtils.getPoint(angular.element(markingSurface.svg), event);
}
function startDrag(hammerEvent) {
$rootScope.$broadcast('markingTools:disable');
markingSurfaceWasEnabled = markingSurface.$isEnabled();
if (markingSurfaceWasEnabled) {
$rootScope.$broadcast('panZoom:disable');
}
hammerSurface.on('panmove', moveDrag);
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 ]);
recognizer.reset = function(force) {
var recognizers = this.recognizers,
session = this.session;
if (session.stopped) {
return;
}
Template.studylistStudy.onRendered(() => {
const instance = Template.instance();
const data = instance.data;
const $row = instance.$('tr.studylistStudy').first();
// Enable HammerJS to allow touch support
const mc = new Hammer.Manager($row.get(0));
const doubleTapRecognizer = new Hammer.Tap({
event: 'doubletap',
taps: 2,
interval: 500,
threshold: 30,
posThreshold: 30
});
const press = new Hammer.Press();
mc.add(press);
mc.add(doubleTapRecognizer);
mc.on('press', function(event) {
handlePress(event, instance);
});
mc.on('doubletap', function(event) {
handleDoubleClick(event, instance);
});
// Check if current row has been previously selected
if (data.selected) {
doSelectRow($row, data);
edgesMerge.each(function(d, i){
var elem = this;
var mc = new Hammer.Manager(elem);
mc.add(new Hammer.Press({
pointerType: Hammer.POINTER_TOUCH
}));
})
}
this.svg.attr('width', this.availableWidth).attr('height', this.availableHeight);
this.mainGroup = this.svg.selectOrAppend('g.main-group');
this.updateMargin();
if (!this.config.width) {
d3.select(window)
.on("resize.tree-designer", function () {
self.updatePlottingRegionSize();
self.redrawDiagramTitle();
});
}
var mc = new Hammer.Manager(this.svg.node(), {touchAction : 'auto'});
mc.add(new Hammer.Press({
pointerType: 'touch'
}));
mc.add(new Hammer.Pinch({
pointerType: 'touch'
}));
var cancel;
mc.on('pinchstart', function(){
self.disableBrush();
})
mc.on('pinch', function(){
cancel = Utils.waitForFinalEvent(()=>self.enableBrush(), 'pinchend', 5000)
})
}