Skip to content

Commit

Permalink
feat(interaction): tooltip 支持移动端
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ authored and hustcc committed Apr 2, 2020
1 parent 4a86b08 commit 8e6cddf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Chart extends View {
pixelRatio,
localRefresh = true,
visible = true,
defaultInteractions = ['tooltip', 'legend-filter', 'legend-active','continuous-filter'],
defaultInteractions = [ 'tooltip', 'legend-filter', 'legend-active', 'continuous-filter' ],
options,
limitInPlot,
theme,
Expand Down
16 changes: 10 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,14 @@ function isPointInView(context: IInteractionContext) {

// 注册 tooltip 的 interaction
registerInteraction('tooltip', {
start: [{ trigger: 'plot:mousemove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } }],
end: [{ trigger: 'plot:mouseleave', action: 'tooltip:hide' }],
start: [
{ trigger: 'plot:mousemove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } },
{ trigger: 'plot:touchmove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } },
],
end: [
{ trigger: 'plot:mouseleave', action: 'tooltip:hide' },
{ trigger: 'plot:touchend', action: 'tooltip:hide' }
],
});

// 移动到 elment 上 active
Expand Down Expand Up @@ -488,8 +494,7 @@ registerInteraction('legend-filter', {
{ trigger: 'legend-item:mouseleave', action: 'cursor:default' },
],
start: [
{ trigger: 'legend-item:click', action: 'list-unchecked:toggle' },
{ trigger: 'legend-item:click', action: 'data-filter:filter' },
{ trigger: 'legend-item:click', action: [ 'list-unchecked:toggle', 'data-filter:filter' ] },
],
});

Expand All @@ -509,8 +514,7 @@ registerInteraction('legend-visible-filter', {
{ trigger: 'legend-item:mouseleave', action: 'cursor:default' },
],
start: [
{ trigger: 'legend-item:click', action: 'list-unchecked:toggle' },
{ trigger: 'legend-item:click', action: 'element-filter:filter' },
{ trigger: 'legend-item:click', action: ['list-unchecked:toggle', 'element-filter:filter'] },
],
});

Expand Down

0 comments on commit 8e6cddf

Please sign in to comment.