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(switch): abnormal loading animation when switching state #2879

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Pending

### Fixes

- Fix `n-menu`'s `dropdown-props` prop can't override `n-dropdown`'s `size` prop, closes [#2868](https://github.com/TuSimple/naive-ui/issues/2868).
- Fix `n-switch` abnormal loading animation when switching state, closes [#2870](https://github.com/TuSimple/naive-ui/issues/2870)

## 2.28.2

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Pending

### Fixes

- 修复 `n-menu` 的 `dropdown-props` 无法覆盖 `n-dropdown` 的 `size` 属性,关闭 [#2868](https://github.com/TuSimple/naive-ui/issues/2868)
- 修复 `n-switch` 切换状态时 loading 动画异常,关闭 [#2870](https://github.com/TuSimple/naive-ui/issues/2870)

## 2.28.2

Expand Down
31 changes: 30 additions & 1 deletion src/switch/demos/enUS/loading.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,34 @@
</markdown>

<template>
<n-switch loading />
<n-space>
<n-switch loading />
<n-switch
:value="activeValue"
:loading="loading"
@update:value="handleChange"
/>
</n-space>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'

export default defineComponent({
setup () {
const activeValue = ref(false)
const loading = ref(false)
return {
activeValue,
loading,
handleChange (value: boolean) {
loading.value = true
setTimeout(() => {
activeValue.value = value
loading.value = false
}, 2000)
}
}
}
})
</script>
32 changes: 31 additions & 1 deletion src/switch/demos/zhCN/loading.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@
# 加载中

</markdown>

<template>
<n-switch loading />
<n-space>
<n-switch loading />
<n-switch
:value="activeValue"
:loading="loading"
@update:value="handleChange"
/>
</n-space>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'

export default defineComponent({
setup () {
const activeValue = ref(false)
const loading = ref(false)
return {
activeValue,
loading,
handleChange (value: boolean) {
loading.value = true
setTimeout(() => {
activeValue.value = value
loading.value = false
}, 2000)
}
}
}
})
</script>
2 changes: 2 additions & 0 deletions src/switch/src/styles/index.cssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default cB('switch', `
transition: color .3s var(--n-bezier);
`, [
iconSwitchTransition({
left: '50%',
top: '50%',
originalTransform: 'translateX(-50%) translateY(-50%)'
})
]),
Expand Down