Skip to content

Commit

Permalink
feat(slider): fix incorrect dot pos caused by repeated init
Browse files Browse the repository at this point in the history
each time init is called, the dots are set to the defaultValue position. Added a flag to filter

fix Tencent#3083
  • Loading branch information
jby0107 committed Aug 19, 2024
1 parent 2223cf7 commit 288e5bc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type dataType = {
prefix: string;
isVisibleToScreenReader: boolean;
identifier: number[];
__inited: boolean;
};

interface boundingClientRect {
Expand All @@ -46,6 +47,10 @@ export default class Slider extends SuperComponent {
`${prefix}-class-cursor`,
];

options = {
pureDataPattern: /^__/,
};

properties = props;

controlledProps = [
Expand Down Expand Up @@ -76,6 +81,7 @@ export default class Slider extends SuperComponent {
prefix,
isVisibleToScreenReader: false,
identifier: [-1, -1],
__inited: false,
};

observers = {
Expand Down Expand Up @@ -218,6 +224,7 @@ export default class Slider extends SuperComponent {
}

async init() {
if (this.data.__inited) return;
const line: boundingClientRect = await getRect(this, '#sliderLine');
const { blockSize } = this.data;
const { theme, vertical } = this.properties;
Expand All @@ -238,6 +245,7 @@ export default class Slider extends SuperComponent {
maxRange,
initialLeft,
initialRight,
__inited: true,
});
this.bus.emit('initial');
}
Expand Down

0 comments on commit 288e5bc

Please sign in to comment.