Skip to content

Commit

Permalink
fix(internal): Correct evaluating inputType condition (#257)
Browse files Browse the repository at this point in the history
On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true.
Evaluate inputType.touch to not be empty and change condition as ('ontouchmove' in window)

Fix #92
Close #257
  • Loading branch information
netil committed Jan 25, 2018
1 parent e7d1b19 commit 4b1f3cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion spec/internals/bb-spec.js
Expand Up @@ -21,10 +21,12 @@ describe("Interface & initialization", () => {
]
}
});
const internal = chart.internal;

expect(chart).not.to.be.null;
expect(d3.select(chart.element).classed("bb")).to.be.true;
expect(chart.internal.svg.node().tagName).to.be.equal("svg");
expect(internal.svg.node().tagName).to.be.equal("svg");
expect(internal.convertInputType()).to.be.equal(internal.inputType);
});

it("should resize correctly in flex container", done => {
Expand Down
5 changes: 3 additions & 2 deletions src/internals/ChartInternal.js
Expand Up @@ -1261,9 +1261,10 @@ export default class ChartInternal {
const hasMouse = config.interaction_inputType_mouse ? ("onmouseover" in window) : false;
let hasTouch = false;

if (config.interaction_inputType_touch) {
if (notEmpty(config.interaction_inputType_touch)) {
// Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
hasTouch = ("ontouchstart" in window) || (window.DocumentTouch && document instanceof window.DocumentTouch);
// On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
hasTouch = ("ontouchmove" in window) || (window.DocumentTouch && document instanceof window.DocumentTouch);
}

return (hasTouch && "touch") || (hasMouse && "mouse") || null;
Expand Down

0 comments on commit 4b1f3cc

Please sign in to comment.