Skip to content

Commit

Permalink
Merge pull request #5038 from camptocamp/remove_snapping_hack
Browse files Browse the repository at this point in the history
Remove snap interaction hack
  • Loading branch information
llienher committed Jul 25, 2019
2 parents 12538bd + bc2971d commit 7880e49
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions contribs/gmf/src/editing/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import * as olBase from 'ol/index.js';
import * as olEvents from 'ol/events.js';
import olCollection from 'ol/Collection.js';
import olFormatWFS from 'ol/format/WFS.js';
import olInteractionSnap, {handleEvent as snapHandleEvent} from 'ol/interaction/Snap.js';
import {handleEvent as handlePointerEvent} from 'ol/interaction/Pointer.js';

import olInteractionSnap from 'ol/interaction/Snap.js';

/**
* The snapping service of GMF. Responsible of collecting the treeCtrls that
Expand Down Expand Up @@ -134,19 +132,12 @@ const exports = function($http, $q, $rootScope, $injector, $timeout, gmfThemes,
class CustomSnap extends olInteractionSnap {
constructor(options) {
super(options);
this.modifierPressed = false;
document.body.addEventListener('keydown', (evt) => {
this.modifierPressed = evt.keyCode === 17; // Ctrl key
this.setActive(evt.keyCode !== 17); // Ctrl key
});
document.body.addEventListener('keyup', () => {
this.modifierPressed = false;
this.setActive(true);
});
this.handleEvent = (evt) => { // horrible hack
if (!this.modifierPressed) {
return snapHandleEvent.call(this, evt);
}
return handlePointerEvent.call(this, evt);
};
}
}

Expand Down

0 comments on commit 7880e49

Please sign in to comment.