Skip to content

Commit 6e40225

Browse files
committed
chore: merge 'feat/tooltip/displayTransition' branch
# Conflicts: # src/component/tooltip/TooltipHTMLContent.ts
2 parents a18d636 + d88a52a commit 6e40225

File tree

6 files changed

+170
-10
lines changed

6 files changed

+170
-10
lines changed

src/component/tooltip/TooltipHTMLContent.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ function assembleCssText(tooltipModel: Model<TooltipOption>, enableTransition?:
186186
const boxShadow = `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowColor}`;
187187

188188
cssText.push('box-shadow:' + boxShadow);
189-
// Animation transition. Do not animate when transitionDuration is 0.
190-
enableTransition && transitionDuration && cssText.push(assembleTransition(transitionDuration, onlyFade));
189+
// Animation transition. Do not animate when transitionDuration <= 0.
190+
enableTransition && transitionDuration > 0 && cssText.push(assembleTransition(transitionDuration, onlyFade));
191191

192192
if (backgroundColor) {
193193
cssText.push('background-color:' + backgroundColor);
@@ -284,6 +284,8 @@ class TooltipHTMLContent {
284284
*/
285285
private _longHideTimeout: number;
286286

287+
private _enableDisplayTransition: boolean;
288+
287289
constructor(
288290
api: ExtensionAPI,
289291
opt: TooltipContentOption
@@ -376,6 +378,9 @@ class TooltipHTMLContent {
376378
// update alwaysShowContent
377379
this._alwaysShowContent = alwaysShowContent;
378380

381+
this._enableDisplayTransition = tooltipModel.get('displayTransition')
382+
&& tooltipModel.get('transitionDuration') > 0;
383+
379384
// update className
380385
this.el.className = tooltipModel.get('className') || '';
381386

@@ -499,9 +504,13 @@ class TooltipHTMLContent {
499504

500505
hide() {
501506
const style = this.el.style;
502-
style.visibility = 'hidden';
503-
style.display = 'none';
504-
style.opacity = '0';
507+
if (this._enableDisplayTransition) {
508+
style.visibility = 'hidden';
509+
style.opacity = '0';
510+
}
511+
else {
512+
style.display = 'none';
513+
}
505514
env.transform3dSupported && (style.willChange = '');
506515
this._show = false;
507516
this._longHideTimeout = setTimeout(() => this._longHide = true, 500) as any;

src/component/tooltip/TooltipModel.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ export interface TooltipOption extends CommonTooltipOption<TopLevelFormatterPara
5151
*/
5252
trigger?: 'item' | 'axis' | 'none'
5353

54-
displayMode?: 'single' | 'multipleByCoordSys';
55-
5654
/**
5755
* 'auto': use html by default, and use non-html if `document` is not defined
5856
* 'html': use html for tooltip
@@ -106,13 +104,11 @@ class TooltipModel extends ComponentModel<TooltipOption> {
106104

107105
alwaysShowContent: false,
108106

109-
displayMode: 'single', // 'single' | 'multipleByCoordSys'
110-
111107
renderMode: 'auto', // 'auto' | 'html' | 'richText'
112108

113109
// whether restraint content inside viewRect.
114110
// If renderMode: 'richText', default true.
115-
// If renderMode: 'html', defaut false (for backward compat).
111+
// If renderMode: 'html', defaults to `false` (for backward compat).
116112
confine: null,
117113

118114
showDelay: 0,
@@ -122,6 +118,8 @@ class TooltipModel extends ComponentModel<TooltipOption> {
122118
// Animation transition time, unit is second
123119
transitionDuration: 0.4,
124120

121+
displayTransition: true,
122+
125123
enterable: false,
126124

127125
backgroundColor: '#fff',

src/util/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,15 @@ export interface CommonTooltipOption<FormatterParams> {
13031303
*/
13041304
enterable?: boolean
13051305

1306+
/**
1307+
* Whether enable display transition when show/hide tooltip.
1308+
* Defaults to `true` for backward compatibility.
1309+
* If set to `false`, the tooltip 'display' will be set to 'none' when hidden.
1310+
* @default true
1311+
* @since v6.0.0
1312+
*/
1313+
displayTransition?: boolean
1314+
13061315
backgroundColor?: ColorString
13071316
borderColor?: ColorString
13081317
borderRadius?: number

test/runTest/actions/__meta__.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/runTest/actions/tooltip-displayTransition.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/tooltip-displayTransition.html

Lines changed: 142 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)