Skip to content

Commit

Permalink
Use pointer events in welcome walkthrough chapter on supported device…
Browse files Browse the repository at this point in the history
…s (re: #5505)
  • Loading branch information
quincylvania committed May 8, 2020
1 parent a781847 commit a16a95e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/ui/intro/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ function clickListener() {
var tooltip = d3_select(null);
var down = {};

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

// `down` keeps track of which buttons/keys are down.
// Setting a property in `down` happens immediately.
// Unsetting a property in `down` is delayed because
Expand Down Expand Up @@ -201,7 +203,7 @@ function clickListener() {
}


function mousedown() {
function pointerdown() {
var button = d3_event.button;
if (button === 0 && !d3_event.ctrlKey) {
tooltip.classed('leftclick', true);
Expand All @@ -212,7 +214,7 @@ function clickListener() {
}


function mouseup() {
function pointerup() {
var button = d3_event.button;
var endTime = d3_event.timeStamp;
var startTime = down[button] || endTime;
Expand Down Expand Up @@ -262,8 +264,8 @@ function clickListener() {
d3_select(window)
.on('keydown.intro', keydown)
.on('keyup.intro', keyup)
.on('mousedown.intro', mousedown)
.on('mouseup.intro', mouseup)
.on(_pointerPrefix + 'down.intro', pointerdown)
.on(_pointerPrefix + 'up.intro', pointerup)
.on('contextmenu.intro', contextmenu);
};

Expand All @@ -272,8 +274,8 @@ function clickListener() {
d3_select(window)
.on('keydown.intro', null)
.on('keyup.intro', null)
.on('mousedown.intro', null)
.on('mouseup.intro', null)
.on(_pointerPrefix + 'down.intro', null)
.on(_pointerPrefix + 'up.intro', null)
.on('contextmenu.intro', null);

tooltip
Expand Down

0 comments on commit a16a95e

Please sign in to comment.