forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:slider): support nzTooltipVisible
close NG-ZORRO#2373 test: add test fix: fix hover handles rebase
- Loading branch information
Wendell
committed
Feb 19, 2019
1 parent
f2fde8c
commit 400d2ac
Showing
33 changed files
with
755 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function getPercent(min: number, max: number, value: number): number { | ||
return (value - min) / (max - min) * 100; | ||
} | ||
|
||
export function getPrecision(num: number): number { | ||
const numStr = num.toString(); | ||
const dotIndex = numStr.indexOf('.'); | ||
return dotIndex >= 0 ? numStr.length - dotIndex - 1 : 0; | ||
} | ||
|
||
export function ensureNumberInRange(num: number, min: number, max: number): number { | ||
if (isNaN(num) || num < min) { | ||
return min; | ||
} else if (num > max) { | ||
return max; | ||
} else { | ||
return num; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
order: 7 | ||
title: | ||
zh-CN: 控制 Tooltip 的显示 | ||
en-US: Control visibility of Tooltip | ||
--- | ||
|
||
## zh-CN | ||
|
||
当 `nzTooltipVisible` 为 `always` 时,将始终显示 ToolTip,为 `never` 时反之则始终不显示,即使在拖动、移入时也是如此。 | ||
|
||
## en-US | ||
|
||
When `nzTooltipVisible` is `always`, Tooltip will show always. And set to `never`, tooltip would never show, even when user is dragging or hovering. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-slider-tooltip', | ||
template: ` | ||
<nz-slider [nzTooltipVisible]="'always'"></nz-slider> | ||
<nz-slider [nzTooltipVisible]="'never'"></nz-slider> | ||
` | ||
}) | ||
export class NzDemoSliderTooltipComponent { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
export type Mark = string | MarkObj; | ||
|
||
export interface MarkObj { | ||
style?: object; | ||
label: string; | ||
} | ||
|
||
export class Marks { | ||
[ key: number ]: Mark; | ||
} | ||
|
||
/** | ||
* Processed steps that would be passed to sub components. | ||
*/ | ||
export interface ExtendedMark { | ||
value: number; | ||
offset: number; | ||
config: Mark; | ||
} | ||
|
||
/** | ||
* Marks that would be rendered. | ||
*/ | ||
export interface DisplayedMark extends ExtendedMark { | ||
active: boolean; | ||
label: string; | ||
style?: object; | ||
} | ||
|
||
/** | ||
* Steps that would be rendered. | ||
*/ | ||
export interface DisplayedStep extends ExtendedMark { | ||
active: boolean; | ||
style?: object; | ||
} | ||
|
||
export type SliderShowTooltip = 'always' | 'never' | 'default'; | ||
|
||
export type SliderValue = number[] | number; | ||
|
||
export interface SliderHandler { | ||
offset: number; | ||
value: number; | ||
active: boolean; | ||
} | ||
|
||
export function isValueARange(value: SliderValue): value is number[] { | ||
if (value instanceof Array) { | ||
return value.length === 2; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
export function isConfigAObject(config: Mark): config is MarkObj { | ||
return config instanceof Object; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getValueTypeNotMatchError(): Error { | ||
return new Error(`The "nzRange" can't match the "nzValue"'s type, please check these properties: "nzRange", "nzValue", "nzDefaultValue".`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<nz-tooltip *ngIf="nzTipFormatter !== null" #tooltip [nzTitle]="tooltipTitle" [nzTrigger]="null"> | ||
<div nz-tooltip [class]="nzClassName" [ngStyle]="style"></div> | ||
<nz-tooltip | ||
*ngIf="nzTipFormatter !== null && nzTooltipVisible !== 'never'" | ||
[nzTitle]="tooltipTitle" | ||
[nzTrigger]="null"> | ||
<div nz-tooltip class="ant-slider-handle" [ngStyle]="style"></div> | ||
</nz-tooltip> | ||
<div *ngIf="nzTipFormatter === null" [class]="nzClassName" [ngStyle]="style"></div> | ||
<div *ngIf="nzTipFormatter === null || nzTooltipVisible === 'never'" class="ant-slider-handle" [ngStyle]="style"></div> |
Oops, something went wrong.