Skip to content

Commit

Permalink
fix: compatible nuxt
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Nov 21, 2021
1 parent a0bebab commit d681176
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/back-top/BackTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineComponent({
},
props,
setup(props) {
let element: HTMLElement | Window = window
let element: HTMLElement | Window
const show: Ref<boolean> = ref(false)
const click = () => {
Expand Down Expand Up @@ -54,7 +54,7 @@ export default defineComponent({
}
onMounted(() => {
if (props.target) element = getHTMLElement()
element = props.target ? getHTMLElement() : window
element.addEventListener('scroll', throttleScroll)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/pull-refresh/PullRefresh.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { RefreshStatus } from './props'
const MAX_DISTANCE = 100
const CONTROL_POSITION = -50
let scroller: HTMLElement | Window = window
let scroller: HTMLElement | Window
export default defineComponent({
name: 'VarPullRefresh',
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/utils/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ export const toSizeUnit = (value: unknown) => {
}

export function requestAnimationFrame(fn: FrameRequestCallback): number {
return window.requestAnimationFrame ? window.requestAnimationFrame(fn) : window.setTimeout(fn, 16)
return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16)
}

export function cancelAnimationFrame(handle: number): void {
window.cancelAnimationFrame ? window.cancelAnimationFrame(handle) : window.clearTimeout(handle)
globalThis.cancelAnimationFrame ? globalThis.cancelAnimationFrame(handle) : globalThis.clearTimeout(handle)
}

export function nextTickFrame(fn: FrameRequestCallback) {
Expand Down

0 comments on commit d681176

Please sign in to comment.