File tree Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ describe("INTERACTION", () => {
30
30
} ;
31
31
} ) ;
32
32
33
+ it ( "inputType should be 'mouse" , ( ) => {
34
+ expect ( chart . internal . inputType ) . to . be . equal ( "mouse" ) ;
35
+ } ) ;
36
+
33
37
it ( "should have 4 event rects properly" , ( ) => {
34
38
const lefts = [ 69 , 130 , 198 , 403 ] ;
35
39
const widths = [ 61 , 68 , 205 , 197.5 ] ;
@@ -406,7 +410,7 @@ describe("INTERACTION", () => {
406
410
} ) ;
407
411
} ) ;
408
412
409
- it ( "set inputType.mouse=false" , ( ) => {
413
+ it ( "set option inputType.mouse=false" , ( ) => {
410
414
args . interaction . inputType . mouse = false ;
411
415
} ) ;
412
416
@@ -528,6 +532,10 @@ describe("INTERACTION", () => {
528
532
} ;
529
533
} ) ;
530
534
535
+ it ( "inputType should be 'touch" , ( ) => {
536
+ expect ( chart . internal . inputType ) . to . be . equal ( "touch" ) ;
537
+ } ) ;
538
+
531
539
it ( "showed each data points tooltip?" , done => {
532
540
util . simulator ( chart . internal . svg . node ( ) , {
533
541
pos : [ 250 , 150 ] ,
Original file line number Diff line number Diff line change @@ -1258,15 +1258,16 @@ export default class ChartInternal {
1258
1258
convertInputType ( ) {
1259
1259
const $$ = this ;
1260
1260
const config = $$ . config ;
1261
- const hasMouse = config . interaction_inputType_mouse ? ( "onmouseover" in window ) : false ;
1261
+ const isMobile = $$ . isMobile ( ) ;
1262
+ const hasMouse = config . interaction_inputType_mouse && ! isMobile ? ( "onmouseover" in window ) : false ;
1262
1263
let hasTouch = false ;
1263
1264
1264
- if ( notEmpty ( config . interaction_inputType_touch ) ) {
1265
+ if ( config . interaction_inputType_touch ) {
1265
1266
// Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
1266
1267
// On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
1267
1268
hasTouch = ( "ontouchmove" in window ) || ( window . DocumentTouch && document instanceof window . DocumentTouch ) ;
1268
1269
}
1269
1270
1270
- return ( hasTouch && "touch " ) || ( hasMouse && "mouse " ) || null ;
1271
+ return ( hasMouse && "mouse " ) || ( hasTouch && "touch " ) || null ;
1271
1272
}
1272
1273
}
Original file line number Diff line number Diff line change 5
5
import ChartInternal from "./ChartInternal" ;
6
6
import { extend } from "./util" ;
7
7
8
+ const ua = window . navigator . userAgent ;
9
+
8
10
extend ( ChartInternal . prototype , {
9
11
isSafari ( ) {
10
- const ua = window . navigator . userAgent ;
11
-
12
- return ua . indexOf ( "Safari" ) >= 0 &&
13
- ua . indexOf ( "Chrome" ) < 0 ;
12
+ return ua . indexOf ( "Safari" ) > - 1 && ! this . isChrome ( ) ;
14
13
} ,
15
14
16
15
isChrome ( ) {
17
- return window . navigator . userAgent
18
- . indexOf ( "Chrome" ) >= 0 ;
16
+ return ua . indexOf ( "Chrome" ) > - 1 ;
17
+ } ,
18
+
19
+ isMobile ( ) {
20
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
21
+ return ua . indexOf ( "Mobi" ) > - 1 ;
19
22
}
20
23
} ) ;
You can’t perform that action at this time.
0 commit comments