Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(module:slider): support nzTooltipVisible #2817

Closed
wants to merge 1 commit into from

Conversation

wzhudev
Copy link
Member

@wzhudev wzhudev commented Jan 21, 2019

close #2373

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #2373

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@wzhudev wzhudev changed the title feat(module:slider): support nzTooltipVisible WIP(module:slider): support nzTooltipVisible Jan 21, 2019
@netlify
Copy link

netlify bot commented Jan 21, 2019

Deploy preview for ng-zorro-master ready!

Built with commit 8155fcd

https://deploy-preview-2817--ng-zorro-master.netlify.com

@netlify
Copy link

netlify bot commented Jan 21, 2019

Deploy preview for ng-zorro-master ready!

Built with commit 81aab73

https://deploy-preview-2817--ng-zorro-master.netlify.com

@codecov
Copy link

codecov bot commented Jan 22, 2019

Codecov Report

Merging #2817 into master will increase coverage by <.01%.
The diff coverage is 92.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2817      +/-   ##
==========================================
+ Coverage   97.36%   97.37%   +<.01%     
==========================================
  Files         524      527       +3     
  Lines       11042    10995      -47     
  Branches      782      793      +11     
==========================================
- Hits        10751    10706      -45     
+ Misses        190      185       -5     
- Partials      101      104       +3
Impacted Files Coverage Δ
components/core/util/getMentions.ts 60% <ø> (ø) ⬆️
components/slider/nz-slider.module.ts 100% <ø> (ø) ⬆️
components/core/util/check.ts 91.17% <ø> (ø) ⬆️
components/slider/nz-slider-track.component.ts 100% <100%> (ø) ⬆️
components/timeline/nz-timeline.component.ts 97.87% <100%> (ø) ⬆️
components/core/util/number.ts 100% <100%> (ø)
components/cascader/nz-cascader.component.ts 99.22% <100%> (ø) ⬆️
components/core/util/array.ts 100% <100%> (ø) ⬆️
components/slider/nz-slider-definitions.ts 100% <100%> (ø)
components/slider/nz-slider-error.ts 50% <50%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2fde8c...81aab73. Read the comment docs.

@wzhudev wzhudev changed the title WIP(module:slider): support nzTooltipVisible feat(module:slider): support nzTooltipVisible Jan 22, 2019
@vthinkxie vthinkxie mentioned this pull request Jan 24, 2019
86 tasks
if (isNaN(num) || num < min) {
return min;
} else if (num > max) {
console.log('captured max');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no console

it('should pass un-covered code testing', () => {
expect(sliderInstance.getValueToOffset()).toBe(sliderInstance.value);
it('should always display tooltip work', () => {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miss test

});

it('should never display tooltip word', () => {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miss test

@@ -28,5 +28,6 @@ To input a value in a range.
| `[nzTipFormatter]` | Slider will pass its value to `tipFormatter`, and display its value in Tooltip, and hide Tooltip when return value is null. | `(value: number) => string` | - |
| `[ngModel]` | The value of slider. When `range` is `false`, use `number`, otherwise, use `[number, number]` | `number|number[]` | - |
| `[nzVertical]` | If true, the slider will be vertical. | `boolean` | `false` |
| `[nzTooltipVisible]` | When set to `always` tooltips are always displayed. When set to `never` they are never displayed | `default|always|never` | `default` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 'default'|'always'|'never'

@@ -29,5 +29,6 @@ title: Slider
| `[nzTipFormatter]` | Slider 会把当前值传给 `nzTipFormatter`,并在 Tooltip 中显示 `nzTipFormatter` 的返回值,若为 null,则隐藏 Tooltip。 | `(value: number) => string` | - |
| `[ngModel]` | 设置当前取值。当 `range` 为 `false` 时,使用 `number`,否则用 `[number, number]` | `number|number[]` | - |
| `[nzVertical]` | 值为 `true` 时,Slider 为垂直方向 | `boolean` | `false` |
| `[nzTooltipVisible]` | 值为 `always` 时总是显示,值为 `never` 时在任何情况下都不显示 | `default|always|never` | `default` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'default'|'always'|'never'

selector : 'nz-slider-handle',
preserveWhitespaces: false,
templateUrl : './nz-slider-handle.component.html'
})
export class NzSliderHandleComponent implements OnChanges {
export class NzSliderHandleComponent implements OnChanges, AfterViewInit, OnDestroy {
@ViewChild('tooltip') tooltip: NzToolTipComponent;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ViewChild(NzToolTipComponent)

}
}
if (nzTooltipVisible && !nzTooltipVisible.isFirstChange()) {
this.tooltip.show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltip may be null

}

// NOTE: run outside of Angular for performance consideration.
this.ngZone.runOutsideAngular(() => {
Copy link
Member

@vthinkxie vthinkxie Feb 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, there is no need to add runOutsideAngular here, use host:{ 'mouseenter' } is ok

}

if (show) {
this.tooltip.show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.tooltip maybe null

Copy link
Member Author

@wzhudev wzhudev Feb 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private toggleTooltip(show: boolean): void {
    if (this.nzTooltipVisible !== 'default' || !this.tooltip) {
      return;
    }

    if (show) {
      this.tooltip.show();
    } else {
      this.tooltip.hide();
    }
  }

If this.tooltip is null the method returns ahead of this.

@wzhudev
Copy link
Member Author

wzhudev commented Feb 19, 2019

@vthinkxie Fixed. Please review again.

close NG-ZORRO#2373

test: add test

fix: fix hover handles

rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slider: minimum value should always of zero position in range mode
2 participants