Skip to content

Commit

Permalink
fix(index-bar): remove useless prop and dont trigger click after call…
Browse files Browse the repository at this point in the history
… scrollTo method
  • Loading branch information
BeADre committed May 7, 2021
1 parent ffc0ba8 commit bba5152
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/varlet-ui/src/index-anchor/IndexAnchor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineComponent({
const { active, sticky, stickyOffsetTop, zIndex } = indexBar
const setOwnTop = () => {
if (!anchorEl.value) return
ownTop.value = (anchorEl.value as RendererNode).$el
? (anchorEl.value as RendererNode).$el.offsetTop
: (anchorEl.value as HTMLDivElement).offsetTop
Expand Down
6 changes: 3 additions & 3 deletions packages/varlet-ui/src/index-bar/IndexBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export default defineComponent({
})
}
const anchorClick = (anchorName: string | number) => {
props.onClick?.(anchorName)
const anchorClick = (anchorName: string | number, manualCall?: boolean) => {
if (manualCall) props.onClick?.(anchorName)
if (anchorName === active.value) return
const indexAnchor = indexAnchors.find(({ name }: IndexAnchorProvider) => anchorName === name.value)
if (!indexAnchor) return
Expand All @@ -84,7 +84,7 @@ export default defineComponent({
// expose
const scrollTo = (index: number | string) => {
requestAnimationFrame(() => anchorClick(index))
requestAnimationFrame(() => anchorClick(index, true))
}
watch(
Expand Down
3 changes: 0 additions & 3 deletions packages/varlet-ui/src/index-bar/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export const props = {
highlightColor: {
type: String,
},
'onUpdate:active': {
type: Function,
},
onClick: {
type: Function,
},
Expand Down

0 comments on commit bba5152

Please sign in to comment.