mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-16 13:08:06 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ecd7cefde | ||
|
|
aafdfdb59c | ||
|
|
453ff6ca20 | ||
|
|
55832b6b99 |
@@ -2,6 +2,15 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [1.2.7](https://github.com/nuxtlabs/ui/compare/v1.2.6...v1.2.7) (2023-04-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **useTimer:** remaining after pause ([aafdfdb](https://github.com/nuxtlabs/ui/commit/aafdfdb59c365c542f93703dd52b4306ac935040))
|
||||
|
||||
### [1.2.6](https://github.com/nuxtlabs/ui/compare/v1.2.5...v1.2.6) (2023-04-04)
|
||||
|
||||
### [1.2.5](https://github.com/nuxtlabs/ui/compare/v1.2.4...v1.2.5) (2023-04-04)
|
||||
|
||||
### [1.2.4](https://github.com/nuxtlabs/ui/compare/v1.2.3...v1.2.4) (2023-04-04)
|
||||
|
||||
@@ -10,6 +10,7 @@ export default defineNuxtConfig({
|
||||
}
|
||||
}
|
||||
},
|
||||
// @ts-ignore
|
||||
modules: [
|
||||
// @ts-ignore
|
||||
nuxtUI
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nuxthq/ui",
|
||||
"version": "1.2.5",
|
||||
"version": "1.2.7",
|
||||
"repository": "https://github.com/nuxtlabs/ui",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
|
||||
@@ -2,16 +2,16 @@ import { ref, computed } from 'vue-demi'
|
||||
import { useTimestamp } from '@vueuse/core'
|
||||
import type { UseTimestampOptions } from '@vueuse/core'
|
||||
|
||||
export function useTimer (cb: (...args: unknown[]) => any, interval: number, options: UseTimestampOptions<true> = { controls: true }) {
|
||||
export function useTimer (cb: (...args: unknown[]) => any, interval: number, options?: UseTimestampOptions<true>) {
|
||||
let timer: number | null = null
|
||||
const timestamp = useTimestamp(options)
|
||||
const { pause: tPause, resume: tResume, timestamp } = useTimestamp({ ...(options || {}), controls: true })
|
||||
const startTime = ref<number | null>(null)
|
||||
|
||||
const remaining = computed(() => {
|
||||
if (!startTime.value) {
|
||||
return
|
||||
return 0
|
||||
}
|
||||
return interval - (timestamp.timestamp.value - startTime.value)
|
||||
return interval - (timestamp.value - startTime.value)
|
||||
})
|
||||
|
||||
function set (...args: unknown[]) {
|
||||
@@ -38,18 +38,18 @@ export function useTimer (cb: (...args: unknown[]) => any, interval: number, opt
|
||||
|
||||
function stop () {
|
||||
clear()
|
||||
timestamp.pause()
|
||||
tPause()
|
||||
}
|
||||
|
||||
function pause () {
|
||||
clear()
|
||||
timestamp.pause()
|
||||
tPause()
|
||||
}
|
||||
|
||||
function resume () {
|
||||
startTime.value = (startTime.value || 0) + (Date.now() - timestamp.timestamp.value)
|
||||
timestamp.resume()
|
||||
set()
|
||||
tResume()
|
||||
startTime.value = (startTime.value || 0) + (Date.now() - timestamp.value)
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
Reference in New Issue
Block a user