@@ -28,6 +28,8 @@ var __extends = (this && this.__extends) || (function () {
28
28
import AccessibilityComponent from '../AccessibilityComponent.js' ;
29
29
import CU from '../Utils/ChartUtilities.js' ;
30
30
var unhideChartElementFromAT = CU . unhideChartElementFromAT ;
31
+ import HU from '../Utils/HTMLUtilities.js' ;
32
+ var getFakeMouseEvent = HU . getFakeMouseEvent ;
31
33
import KeyboardNavigationHandler from '../KeyboardNavigationHandler.js' ;
32
34
import U from '../../Core/Utilities.js' ;
33
35
var attr = U . attr , pick = U . pick ;
@@ -36,33 +38,11 @@ var attr = U.attr, pick = U.pick;
36
38
* Functions
37
39
*
38
40
* */
39
- /**
40
- * Pan along axis in a direction (1 or -1), optionally with a defined
41
- * granularity (number of steps it takes to walk across current view)
42
- * @private
43
- */
44
- function axisPanStep ( axis , direction , granularity ) {
45
- var gran = granularity || 3 ;
46
- var extremes = axis . getExtremes ( ) ;
47
- var step = ( extremes . max - extremes . min ) / gran * direction ;
48
- var newMax = extremes . max + step ;
49
- var newMin = extremes . min + step ;
50
- var size = newMax - newMin ;
51
- if ( direction < 0 && newMin < extremes . dataMin ) {
52
- newMin = extremes . dataMin ;
53
- newMax = newMin + size ;
54
- }
55
- else if ( direction > 0 && newMax > extremes . dataMax ) {
56
- newMax = extremes . dataMax ;
57
- newMin = newMax - size ;
58
- }
59
- axis . setExtremes ( newMin , newMax ) ;
60
- }
61
41
/**
62
42
* @private
63
43
*/
64
44
function chartHasMapZoom ( chart ) {
65
- return ! ! ( ( chart . mapZoom ) &&
45
+ return ! ! ( ( chart . mapView ) &&
66
46
chart . mapNavigation &&
67
47
chart . mapNavigation . navButtons . length ) ;
68
48
}
@@ -213,16 +193,27 @@ var ZoomComponent = /** @class */ (function (_super) {
213
193
} ) ;
214
194
} ;
215
195
/**
196
+ * Arrow key panning for maps.
216
197
* @private
217
- * @param {Highcharts.KeyboardNavigationHandler } keyboardNavigationHandler
218
- * @param {number } keyCode
198
+ * @param {Highcharts.KeyboardNavigationHandler } keyboardNavigationHandler The handler context.
199
+ * @param {number } keyCode Key pressed.
219
200
* @return {number } Response code
220
201
*/
221
202
ZoomComponent . prototype . onMapKbdArrow = function ( keyboardNavigationHandler , keyCode ) {
222
- var keys = this . keyCodes , panAxis = ( keyCode === keys . up || keyCode === keys . down ) ?
223
- 'yAxis' : 'xAxis' , stepDirection = ( keyCode === keys . left || keyCode === keys . up ) ?
224
- - 1 : 1 ;
225
- axisPanStep ( this . chart [ panAxis ] [ 0 ] , stepDirection ) ;
203
+ var chart = this . chart , keys = this . keyCodes , target = chart . container , isY = keyCode === keys . up || keyCode === keys . down , stepDirection = ( keyCode === keys . left || keyCode === keys . up ) ?
204
+ 1 : - 1 , granularity = 10 , diff = ( isY ? chart . plotHeight : chart . plotWidth ) /
205
+ granularity * stepDirection ,
206
+ // Randomize since same mousedown coords twice is ignored in MapView
207
+ r = Math . random ( ) * 10 , startPos = {
208
+ x : target . offsetLeft + chart . plotLeft + chart . plotWidth / 2 + r ,
209
+ y : target . offsetTop + chart . plotTop + chart . plotHeight / 2 + r
210
+ } , endPos = isY ? { x : startPos . x , y : startPos . y + diff } :
211
+ { x : startPos . x + diff , y : startPos . y } ;
212
+ [
213
+ getFakeMouseEvent ( 'mousedown' , startPos ) ,
214
+ getFakeMouseEvent ( 'mousemove' , endPos ) ,
215
+ getFakeMouseEvent ( 'mouseup' , endPos )
216
+ ] . forEach ( function ( e ) { return target . dispatchEvent ( e ) ; } ) ;
226
217
return keyboardNavigationHandler . response . success ;
227
218
} ;
228
219
/**
@@ -240,7 +231,9 @@ var ZoomComponent = /** @class */ (function (_super) {
240
231
// Deselect old
241
232
chart . mapNavigation . navButtons [ this . focusedMapNavButtonIx ] . setState ( 0 ) ;
242
233
if ( isMoveOutOfRange ) {
243
- chart . mapZoom ( ) ; // Reset zoom
234
+ if ( chart . mapView ) {
235
+ chart . mapView . zoomBy ( ) ; // Reset zoom
236
+ }
244
237
return response [ isBackwards ? 'prev' : 'next' ] ;
245
238
}
246
239
// Select other button
@@ -251,12 +244,13 @@ var ZoomComponent = /** @class */ (function (_super) {
251
244
return response . success ;
252
245
} ;
253
246
/**
247
+ * Called on map button click.
254
248
* @private
255
- * @param {Highcharts.KeyboardNavigationHandler } keyboardNavigationHandler
249
+ * @param {Highcharts.KeyboardNavigationHandler } keyboardNavigationHandler The handler context object
256
250
* @return {number } Response code
257
251
*/
258
252
ZoomComponent . prototype . onMapKbdClick = function ( keyboardNavigationHandler ) {
259
- var el = this . chart . mapNavButtons [ this . focusedMapNavButtonIx ] . element ;
253
+ var el = this . chart . mapNavigation . navButtons [ this . focusedMapNavButtonIx ] . element ;
260
254
this . fakeClickEvent ( el ) ;
261
255
return keyboardNavigationHandler . response . success ;
262
256
} ;
0 commit comments