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

fix: change the scrollbar and legend hover style. #313

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/component",
"version": "1.0.0-beta.2",
"version": "1.0.0",
"description": "Visualization components for AntV, based on G.",
"license": "MIT",
"main": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type PrefixStyleProps<T extends Record<string, any>, P extends string> =
[K in keyof T as K extends `show${infer S}`
? `show${Capitalize<P>}${S}`
: K extends string
? `${P}${Capitalize<K>}`
: never]: T[K];
? `${P}${Capitalize<K>}`
: never]: T[K];
};

export type CallableStyleProps<T extends Record<string, any>, P extends any[]> = {
Expand Down
11 changes: 9 additions & 2 deletions src/ui/legend/continuous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CustomEvent } from '@antv/g';
import { Linear } from '@antv/scale';
import { clamp, isUndefined } from '@antv/util';
import { Component } from '../../core';
import type { DisplayObject, TextStyleProps } from '../../shapes';
import type { BaseStyleProps, DisplayObject, TextStyleProps } from '../../shapes';
import { Group } from '../../shapes';
import { Point } from '../../types';
import {
Expand Down Expand Up @@ -573,6 +573,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
this.ribbon.on('pointerdown', this.onDragStart('ribbon'));
this.ribbon.on('pointermove', this.onHovering);
this.addEventListener('pointerout', this.hideIndicator);
this.addEventListener('pointerover', this.changeCursor('pointer'));
Runtus marked this conversation as resolved.
Show resolved Hide resolved
}

private onHovering = (e: any) => {
Expand Down Expand Up @@ -649,7 +650,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
};

private onDragEnd = () => {
this.style.cursor = 'default';
this.style.cursor = 'pointer';
document.removeEventListener('mousemove', this.onDragging);
document.removeEventListener('touchmove', this.onDragging);
document.removeEventListener('mouseup', this.onDragEnd);
Expand Down Expand Up @@ -737,4 +738,10 @@ export class Continuous extends Component<ContinuousStyleProps> {
});
this.dispatchEvent(evt as any);
}

private changeCursor(cursor: BaseStyleProps['cursor'] = 'default') {
return (e: any) => {
this.style.cursor = cursor;
};
}
}
5 changes: 4 additions & 1 deletion src/ui/slider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ export class Slider extends Component<SliderStyleProps> {
this.attr('cursor', 'grabbing');
});
this.addEventListener('pointerup', () => {
this.attr('cursor', 'grab');
this.attr('cursor', 'pointer');
});
this.addEventListener('pointerover', () => {
this.attr('cursor', 'pointer');
});
} else {
this.on('pointerdown', that.onDragStart('track'));
Expand Down