diff --git a/packages/varlet-ui/src/snackbar/core.less b/packages/varlet-ui/src/snackbar/core.less
index bf1db6c8663..dbd4fc61a5d 100644
--- a/packages/varlet-ui/src/snackbar/core.less
+++ b/packages/varlet-ui/src/snackbar/core.less
@@ -9,6 +9,7 @@
top: 0;
bottom: 0;
pointer-events: none;
+ z-index: 10;
}
.var-pointer-auto {
@@ -24,6 +25,7 @@
right: 0;
bottom: 0;
transition: all 0.15s cubic-bezier(0, 0, 0.2, 1);
+ z-index: 10;
&__wrapper {
width: 256px;
diff --git a/packages/varlet-ui/src/snackbar/core.vue b/packages/varlet-ui/src/snackbar/core.vue
index c1362634897..a57ca2e0c39 100644
--- a/packages/varlet-ui/src/snackbar/core.vue
+++ b/packages/varlet-ui/src/snackbar/core.vue
@@ -2,17 +2,15 @@
snackbar事件
-
- 打开与关闭回调
-
+ 打开与关闭回调
打开动画与关闭动画结束时回调
@@ -99,18 +53,14 @@
{{ text }}
-
- close
-
+ close
{{ text }}
-
- close
-
+ close
@@ -151,7 +101,7 @@ export default defineComponent({
[Button.name]: Button,
},
setup() {
- const text: Ref = ref("Hello, I'm a snackbar-core")
+ const text: Ref = ref("Hello, I'm a snackbar")
const isAllowMultiple: Ref = ref(true)
const shows: any = reactive({
show1: false,
@@ -171,7 +121,7 @@ export default defineComponent({
const create = (type: any) => {
const snackbar: any = Snackbar({
- content: "Hello, I'm a snackbar-core",
+ content: "Hello, I'm a snackbar",
type,
})
setTimeout(function () {
@@ -181,14 +131,22 @@ export default defineComponent({
const createMethod = (type: SnackbarType) => {
Snackbar[type]({
- content: "Hello, I'm a snackbar-core",
+ content: "Hello, I'm a snackbar",
forbidClick: type === 'loading',
+ loadingSize: 'small',
})
+ if (type === 'loading') {
+ setTimeout(() => {
+ Snackbar.success({
+ content: "Hello, I'm a snackbar",
+ })
+ }, 3000)
+ }
}
const createPosition = (position: 'top' | 'center' | 'bottom') => {
Snackbar({
- content: "Hello, I'm a snackbar-core",
+ content: "Hello, I'm a snackbar",
position,
})
}
diff --git a/packages/varlet-ui/src/utils/elements.ts b/packages/varlet-ui/src/utils/elements.ts
index 3be338f79fd..9d2a381a0c8 100644
--- a/packages/varlet-ui/src/utils/elements.ts
+++ b/packages/varlet-ui/src/utils/elements.ts
@@ -1,7 +1,3 @@
-import { inBrowser } from './shared'
-
-const root = (inBrowser ? window : global) as Window
-
export function getTop(element: HTMLElement): number {
const { top } = element.getBoundingClientRect()
@@ -88,5 +84,5 @@ export function remToPx(rem: string | number): number {
}
export function requestAnimationFrame(fn: FrameRequestCallback): number {
- return root.requestAnimationFrame ? root.requestAnimationFrame(fn) : root.setTimeout(fn, 16)
+ return window.requestAnimationFrame ? window.requestAnimationFrame(fn) : window.setTimeout(fn, 16)
}
diff --git a/packages/varlet-ui/src/utils/shared.ts b/packages/varlet-ui/src/utils/shared.ts
index 4db0881275f..2283b416849 100644
--- a/packages/varlet-ui/src/utils/shared.ts
+++ b/packages/varlet-ui/src/utils/shared.ts
@@ -8,8 +8,6 @@ export interface CacheInstance {
remove(key: T): void
}
-export const inBrowser = typeof window !== 'undefined'
-
export const isString = (val: unknown): val is string => typeof val === 'string'
export const isNumber = (val: unknown): val is number => typeof val === 'number'