Skip to content

Commit

Permalink
Update more mouse events to use pointer events if available (re: #5505)
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed May 8, 2020
1 parent 77552c4 commit 95dc16b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/modes/select_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function modeSelectData(context, selectedDatum) {
// Return to browse mode if selected DOM elements have
// disappeared because the user moved them out of view..
var source = d3_event && d3_event.type === 'zoom' && d3_event.sourceEvent;
if (drawn && source && (source.type === 'mousemove' || source.type === 'touchmove')) {
if (drawn && source && (source.type === 'pointermove' || source.type === 'mousemove' || source.type === 'touchmove')) {
context.enter(modeBrowse(context));
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/modes/select_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function modeSelectError(context, selectedErrorID, selectedErrorService)
// Return to browse mode if selected DOM elements have
// disappeared because the user moved them out of view..
var source = d3_event && d3_event.type === 'zoom' && d3_event.sourceEvent;
if (drawn && source && (source.type === 'mousemove' || source.type === 'touchmove')) {
if (drawn && source && (source.type === 'pointermove' || source.type === 'mousemove' || source.type === 'touchmove')) {
context.enter(modeBrowse(context));
}

Expand Down
2 changes: 1 addition & 1 deletion modules/modes/select_note.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function modeSelectNote(context, selectedNoteID) {
// Return to browse mode if selected DOM elements have
// disappeared because the user moved them out of view..
var source = d3_event && d3_event.type === 'zoom' && d3_event.sourceEvent;
if (drawn && source && (source.type === 'mousemove' || source.type === 'touchmove')) {
if (drawn && source && (source.type === 'pointermove' || source.type === 'mousemove' || source.type === 'touchmove')) {
context.enter(modeBrowse(context));
}

Expand Down
10 changes: 6 additions & 4 deletions modules/services/streetside.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,16 @@ export default {

_pannellumViewer = window.pannellum.viewer('ideditor-viewer-streetside', options);

var pointerPrefix = 'PointerEvent' in window ? 'pointer' : 'mouse';

_pannellumViewer
.on('mousedown', () => {
.on(pointerPrefix + 'down', () => {
d3_select(window)
.on('mousemove.pannellum', () => { dispatch.call('viewerChanged'); });
.on(pointerPrefix + 'move.pannellum', () => { dispatch.call('viewerChanged'); });
})
.on('mouseup', () => {
.on(pointerPrefix + 'up', () => {
d3_select(window)
.on('mousemove.pannellum', null);
.on(pointerPrefix + 'move.pannellum', null);

// continue dispatching events for a few seconds, in case viewer has inertia.
let t = d3_timer(elapsed => {
Expand Down
4 changes: 2 additions & 2 deletions modules/ui/intro/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function uiIntroLine(context, reveal) {


function retryIntersect() {
d3_select(window).on('mousedown.intro', eventCancel, true);
d3_select(window).on('pointerdown.intro mousedown.intro', eventCancel, true);

var box = pad(tulipRoadIntersection, 80, context);
reveal(box,
Expand Down Expand Up @@ -1054,7 +1054,7 @@ export function uiIntroLine(context, reveal) {

chapter.exit = function() {
timeouts.forEach(window.clearTimeout);
d3_select(window).on('mousedown.intro', null, true);
d3_select(window).on('pointerdown.intro mousedown.intro', null, true);
context.on('enter.intro exit.intro', null);
context.map().on('move.intro drawn.intro', null);
context.history().on('change.intro', null);
Expand Down
4 changes: 2 additions & 2 deletions modules/ui/panels/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export function uiPanelLocation(context) {
selection.call(redraw);

context.surface()
.on('mousemove.info-location', function() {
.on(('PointerEvent' in window ? 'pointer' : 'mouse') + 'move.info-location', function() {
selection.call(redraw);
});
};

panel.off = function() {
context.surface()
.on('mousemove.info-location', null);
.on('.info-location', null);
};

panel.id = 'location';
Expand Down
6 changes: 1 addition & 5 deletions modules/ui/sections/feature_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ export function uiSectionFeatureType(context) {
.on('click', function() {
dispatch.call('choose', this, _presets);
})
.on('mousedown', function() {
d3_event.preventDefault();
d3_event.stopPropagation();
})
.on('mouseup', function() {
.on('pointerdown pointerup mousedown mouseup', function() {
d3_event.preventDefault();
d3_event.stopPropagation();
});
Expand Down

0 comments on commit 95dc16b

Please sign in to comment.