MCPcopy Create free account
hub / github.com/apache/echarts / getSlidedAxisExpandWindow

Method getSlidedAxisExpandWindow

src/coord/parallel/Parallel.ts:415–475  ·  view source on GitHub ↗

* @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.

(point: number[])

Source from the content-addressed store, hash-verified

413 * @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.
414 */
415 getSlidedAxisExpandWindow(point: number[]): {
416 axisExpandWindow: number[],
417 behavior: SlidedAxisExpandBehavior
418 } {
419 const layoutInfo = this._makeLayoutInfo();
420 const pixelDimIndex = layoutInfo.pixelDimIndex;
421 let axisExpandWindow = layoutInfo.axisExpandWindow.slice();
422 const winSize = axisExpandWindow[1] - axisExpandWindow[0];
423 const extent = [0, layoutInfo.axisExpandWidth * (layoutInfo.axisCount - 1)];
424
425 // Out of the area of coordinate system.
426 if (!this.containPoint(point)) {
427 return {behavior: 'none', axisExpandWindow: axisExpandWindow};
428 }
429
430 // Convert the point from global to expand coordinates.
431 const pointCoord = point[pixelDimIndex] - layoutInfo.layoutBase - layoutInfo.axisExpandWindow0Pos;
432
433 // For dragging operation convenience, the window should not be
434 // slided when mouse is the center area of the window.
435 let delta;
436 let behavior: SlidedAxisExpandBehavior = 'slide';
437 const axisCollapseWidth = layoutInfo.axisCollapseWidth;
438 const triggerArea = this._model.get('axisExpandSlideTriggerArea');
439 // But consider touch device, jump is necessary.
440 const useJump = triggerArea[0] != null;
441
442 if (axisCollapseWidth) {
443 if (useJump && axisCollapseWidth && pointCoord < winSize * triggerArea[0]) {
444 behavior = 'jump';
445 delta = pointCoord - winSize * triggerArea[2];
446 }
447 else if (useJump && axisCollapseWidth && pointCoord > winSize * (1 - triggerArea[0])) {
448 behavior = 'jump';
449 delta = pointCoord - winSize * (1 - triggerArea[2]);
450 }
451 else {
452 (delta = pointCoord - winSize * triggerArea[1]) >= 0
453 && (delta = pointCoord - winSize * (1 - triggerArea[1])) <= 0
454 && (delta = 0);
455 }
456 delta *= layoutInfo.axisExpandWidth / axisCollapseWidth;
457 delta
458 ? sliderMove(delta, axisExpandWindow, extent, 'all')
459 // Avoid nonsense triger on mousemove.
460 : (behavior = 'none');
461 }
462 // When screen is too narrow, make it visible and slidable, although it is hard to interact.
463 else {
464 const winSize2 = axisExpandWindow[1] - axisExpandWindow[0];
465 const pos = extent[1] * pointCoord / winSize2;
466 axisExpandWindow = [mathMax(0, pos - winSize2 / 2)];
467 axisExpandWindow[1] = mathMin(extent[1], axisExpandWindow[0] + winSize2);
468 axisExpandWindow[0] = axisExpandWindow[1] - winSize2;
469 }
470
471 return {
472 axisExpandWindow: axisExpandWindow,

Callers 1

ParallelView.tsFile · 0.80

Calls 4

_makeLayoutInfoMethod · 0.95
containPointMethod · 0.95
sliderMoveFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected