@rokkit/chart 1.0.0-next.29 → 1.0.0-next.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/chart/Chart.svelte +1 -1
- package/src/chart/Swatch.svelte +1 -1
- package/src/chart/SwatchButton.svelte +1 -1
- package/src/chart/SwatchGrid.svelte +48 -48
- package/src/chart/Symbol.svelte +3 -0
- package/src/chart/TimelapseChart.svelte +1 -1
- package/src/chart/Timer.svelte +2 -2
- package/src/chart.js +11 -9
- package/src/components/lib/chart.js +1 -1
- package/src/components/store.js +10 -10
- package/src/elements/ColorRamp.svelte +1 -1
- package/src/elements/Symbol.svelte +1 -1
- package/src/funnel.svelte +2 -2
- package/src/index.js +1 -1
- package/src/plots/BoxPlot.svelte +46 -46
- package/src/plots/HeatMapCalendar.svelte +2 -2
- package/src/plots/RankBarPlot.svelte +1 -1
- package/src/plots/ScatterPlot.svelte +22 -22
- package/src/plots/ViolinPlot.svelte +6 -6
- package/src/plots/heatmap.js +1 -1
- package/src/lib/timer.js +0 -44
- package/src/plots/HeatMap.svelte +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/chart",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.34",
|
|
4
4
|
"description": "Components for making interactive charts.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,28 +13,27 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@sveltejs/vite-plugin-svelte": "^2.2
|
|
17
|
-
"@testing-library/svelte": "^
|
|
18
|
-
"@vitest/ui": "~0.
|
|
19
|
-
"eslint": "^8.40.0",
|
|
16
|
+
"@sveltejs/vite-plugin-svelte": "^2.4.2",
|
|
17
|
+
"@testing-library/svelte": "^4.0.3",
|
|
18
|
+
"@vitest/ui": "~0.32.3",
|
|
20
19
|
"js-yaml": "^4.1.0",
|
|
21
|
-
"jsdom": "^22.
|
|
22
|
-
"svelte": "^
|
|
23
|
-
"typescript": "^5.
|
|
24
|
-
"vite": "^4.3.
|
|
25
|
-
"vitest": "~0.
|
|
26
|
-
"
|
|
27
|
-
"shared-config": "1.0.0-next.28"
|
|
20
|
+
"jsdom": "^22.1.0",
|
|
21
|
+
"svelte": "^4.0.1",
|
|
22
|
+
"typescript": "^5.1.6",
|
|
23
|
+
"vite": "^4.3.9",
|
|
24
|
+
"vitest": "~0.32.3",
|
|
25
|
+
"shared-config": "1.0.0-next.34"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"d3-array": "^3.2.
|
|
28
|
+
"d3-array": "^3.2.4",
|
|
31
29
|
"d3-collection": "^1.0.7",
|
|
32
30
|
"d3-scale": "^4.0.2",
|
|
33
31
|
"d3-shape": "^3.2.0",
|
|
34
32
|
"date-fns": "^2.30.0",
|
|
35
33
|
"ramda": "^0.29.0",
|
|
34
|
+
"rokkit": "1.0.0-next.33",
|
|
36
35
|
"yootils": "^0.3.1",
|
|
37
|
-
"@rokkit/core": "1.0.0-next.
|
|
36
|
+
"@rokkit/core": "1.0.0-next.34"
|
|
38
37
|
},
|
|
39
38
|
"files": [
|
|
40
39
|
"src/**/*.js",
|
|
@@ -52,12 +51,13 @@
|
|
|
52
51
|
}
|
|
53
52
|
},
|
|
54
53
|
"scripts": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
54
|
+
"format": "prettier --write .",
|
|
55
|
+
"lint": "eslint --fix .",
|
|
57
56
|
"test:ci": "vitest run",
|
|
58
57
|
"test:ui": "vitest --ui",
|
|
59
58
|
"test": "vitest",
|
|
60
59
|
"coverage": "vitest run --coverage",
|
|
61
|
-
"
|
|
60
|
+
"latest": "pnpm upgrade --latest && pnpm test:ci",
|
|
61
|
+
"release": "tsc && pnpm publish --access public"
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/chart/Chart.svelte
CHANGED
package/src/chart/Swatch.svelte
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<button
|
|
15
|
-
class="
|
|
15
|
+
class="h-10 w-10 flex items-center justify-center rounded bg-gray-100 p-1 shadow-md hover:bg-primary-300"
|
|
16
16
|
class:isCurrent
|
|
17
17
|
on:click
|
|
18
18
|
on:mouseover
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
import SwatchButton from './SwatchButton.svelte'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export let columns
|
|
5
|
+
export let rows
|
|
6
|
+
export let items
|
|
7
|
+
let grid
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
function toGrid(columns, rows, patterns) {
|
|
10
|
+
const count = patterns.length
|
|
11
|
+
if (columns > 0) {
|
|
12
|
+
rows = Math.ceil(count / columns)
|
|
13
|
+
} else if (rows > 0) {
|
|
14
|
+
columns = Math.ceil(count / rows)
|
|
15
|
+
} else {
|
|
16
|
+
columns = Math.ceil(Math.sqrt(count))
|
|
17
|
+
rows = Math.ceil(count / columns)
|
|
18
|
+
}
|
|
19
|
+
const grid = [...Array(rows).keys()].map((row) =>
|
|
20
|
+
[...Array(columns).keys()]
|
|
21
|
+
.filter((column) => row * columns + column < count)
|
|
22
|
+
.map((column) => ({
|
|
23
|
+
item: patterns[row * columns + column],
|
|
24
|
+
isCurrent: false
|
|
25
|
+
}))
|
|
26
|
+
)
|
|
27
|
+
return grid
|
|
28
|
+
}
|
|
29
|
+
let previous
|
|
30
|
+
function handleClick(row, column) {
|
|
31
|
+
console.log(row, column, grid)
|
|
32
|
+
if (previous) {
|
|
33
|
+
grid[previous.row][previous.column].isCurrent = false
|
|
34
|
+
}
|
|
35
|
+
grid[row][column].isCurrent = true
|
|
36
|
+
previous = { row, column }
|
|
37
|
+
}
|
|
38
|
+
$: grid = toGrid(columns, rows, items)
|
|
39
|
+
$: console.log(grid)
|
|
40
40
|
</script>
|
|
41
41
|
|
|
42
42
|
<row class="flex flex-col gap-2">
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
{#each grid as items, row}
|
|
44
|
+
<div class="flex flex-row gap-2">
|
|
45
|
+
{#each items as { item, isCurrent }, column}
|
|
46
|
+
<SwatchButton
|
|
47
|
+
shape="shurikan"
|
|
48
|
+
pattern={item}
|
|
49
|
+
on:click={() => handleClick(row, column)}
|
|
50
|
+
{isCurrent}
|
|
51
|
+
/>
|
|
52
|
+
{/each}
|
|
53
|
+
</div>
|
|
54
|
+
{/each}
|
|
55
55
|
</row>
|
package/src/chart/Symbol.svelte
CHANGED
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
// Old data set needs exit animation, new data set needs entry animation
|
|
88
88
|
</script>
|
|
89
89
|
|
|
90
|
-
<svg viewBox="0 0 {phased.width} {phased.height}" class="flex
|
|
90
|
+
<svg viewBox="0 0 {phased.width} {phased.height}" class="chart flex">
|
|
91
91
|
<Grid />
|
|
92
92
|
<Axis orient="bottom" />
|
|
93
93
|
<Axis orient="left" />
|
package/src/chart/Timer.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { elapsed, timer } from '
|
|
3
|
+
import { elapsed, timer } from 'rokkit/stores'
|
|
4
4
|
|
|
5
5
|
const dispatch = createEventDispatcher()
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
|
-
<div class="flex flex-row gap-2
|
|
23
|
+
<div class="timer flex flex-row gap-2">
|
|
24
24
|
<button on:click|preventDefault={() => (isEnabled = true)}>play</button>
|
|
25
25
|
<button on:click|preventDefault={() => (isEnabled = false)}>pause</button>
|
|
26
26
|
<button on:click|preventDefault={onReset}>reset</button>
|
package/src/chart.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export function scales(data, aes, opts) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// export function scales(data, aes, opts) {
|
|
2
|
+
// const { x, y } = aes
|
|
3
|
+
// const { width, height, flipCoords } = {
|
|
4
|
+
// width: 800,
|
|
5
|
+
// height: 600,
|
|
6
|
+
// flipCoords: false,
|
|
7
|
+
// ...opts
|
|
8
|
+
// }
|
|
9
|
+
|
|
10
|
+
// return { x, y, width, height, flipCoords }
|
|
11
|
+
// }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nest } from 'd3-collection'
|
|
2
|
-
import { max, quantile, ascending } from 'd3-array'
|
|
2
|
+
import { max, quantile, ascending, bin } from 'd3-array'
|
|
3
3
|
import { scaleLinear } from 'd3-scale'
|
|
4
4
|
import { area, curveCatmullRom } from 'd3-shape'
|
|
5
5
|
import { getScale } from './utils'
|
package/src/components/store.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { writable } from 'svelte/store'
|
|
2
|
-
|
|
3
|
-
function createChart() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
// import { writable } from 'svelte/store'
|
|
2
|
+
import { tweened, cubicOut } from 'svelte/motion'
|
|
3
|
+
// function createChart() {
|
|
4
|
+
// const { subscribe, set } = writable({
|
|
5
|
+
// data: [],
|
|
6
|
+
// x: '',
|
|
7
|
+
// y: ''
|
|
8
|
+
// })
|
|
9
|
+
// return { subscribe, set }
|
|
10
|
+
// }
|
|
11
11
|
|
|
12
12
|
export function animatedChart(input, key, valueFields = [], previous = []) {
|
|
13
13
|
const previousKeys = new Set(previous.map((item) => item[key]))
|
package/src/funnel.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script context="module">
|
|
1
|
+
<!-- <script context="module">
|
|
2
2
|
/**
|
|
3
3
|
* @type {import('@sveltejs/kit').Load}
|
|
4
4
|
*/
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
error: new Error(`Could not load ${url}`)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
</script>
|
|
22
|
+
</script> -->
|
|
23
23
|
|
|
24
24
|
<script>
|
|
25
25
|
import { FunnelPlot, Chart } from '@rokkit/chart'
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// export { aes } from './lib/aes'
|
|
2
2
|
// export { timelapse } from './lib/timelapse'
|
|
3
3
|
// export { axisTicks } from './lib/axis'
|
|
4
|
-
export { timer, elapsed } from './lib/timer'
|
|
4
|
+
// export { timer, elapsed } from './lib/timer'
|
|
5
5
|
// export { default as Chart } from './chart/Chart.svelte'
|
|
6
6
|
// export { default as Axis } from './chart/Axis.svelte'
|
|
7
7
|
export { default as Swatch } from './chart/Swatch.svelte'
|
package/src/plots/BoxPlot.svelte
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
let chart = getContext('chart')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export let whisker = true
|
|
7
|
+
export let boxWidth = 150
|
|
8
|
+
export let stroke = 'green'
|
|
9
|
+
export let fill = '#69b3a2' // fixed color or attribute to be used for color
|
|
10
|
+
export let scaleFill = () => fill // defaults to fill color
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
$: data = $chart.summary()
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
{#each data as { key, value }}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
16
|
+
<rect
|
|
17
|
+
width={boxWidth}
|
|
18
|
+
height={$chart.axis.y.scale(value.q1) - $chart.axis.y.scale(value.q3)}
|
|
19
|
+
x={$chart.axis.x.scale(key) - boxWidth / 2}
|
|
20
|
+
y={$chart.axis.y.scale(value.q3)}
|
|
21
|
+
fill={scaleFill(value[fill])}
|
|
22
|
+
{stroke}
|
|
23
|
+
/>
|
|
24
|
+
<line
|
|
25
|
+
x1={$chart.axis.x.scale(key) - boxWidth / 2}
|
|
26
|
+
x2={$chart.axis.x.scale(key) + boxWidth / 2}
|
|
27
|
+
y1={$chart.axis.y.scale(value.median)}
|
|
28
|
+
y2={$chart.axis.y.scale(value.median)}
|
|
29
|
+
{stroke}
|
|
30
|
+
/>
|
|
31
|
+
<line
|
|
32
|
+
x1={$chart.axis.x.scale(key)}
|
|
33
|
+
x2={$chart.axis.x.scale(key)}
|
|
34
|
+
y1={$chart.axis.y.scale(value.min)}
|
|
35
|
+
y2={$chart.axis.y.scale(value.max)}
|
|
36
|
+
{stroke}
|
|
37
|
+
/>
|
|
38
|
+
{#if whisker}
|
|
39
|
+
<line
|
|
40
|
+
x1={$chart.axis.x.scale(key) - boxWidth / 8}
|
|
41
|
+
x2={$chart.axis.x.scale(key) + boxWidth / 8}
|
|
42
|
+
y1={$chart.axis.y.scale(value.min)}
|
|
43
|
+
y2={$chart.axis.y.scale(value.min)}
|
|
44
|
+
{stroke}
|
|
45
|
+
/>
|
|
46
|
+
<line
|
|
47
|
+
x1={$chart.axis.x.scale(key) - boxWidth / 8}
|
|
48
|
+
x2={$chart.axis.x.scale(key) + boxWidth / 8}
|
|
49
|
+
y1={$chart.axis.y.scale(value.max)}
|
|
50
|
+
y2={$chart.axis.y.scale(value.max)}
|
|
51
|
+
{stroke}
|
|
52
|
+
/>
|
|
53
|
+
{/if}
|
|
54
54
|
{/each}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { summarize, heatmap } from './heatmap'
|
|
3
3
|
import { interpolateHsl } from 'd3-interpolate'
|
|
4
4
|
import { scaleLinear } from 'd3-scale'
|
|
5
|
-
import ContinuousLegend from '../elements/ContinuousLegend.svelte'
|
|
5
|
+
// import ContinuousLegend from '../elements/ContinuousLegend.svelte'
|
|
6
6
|
import DiscreteLegend from '../elements/DiscreteLegend.svelte'
|
|
7
7
|
import ColorRamp from '../elements/ColorRamp.svelte'
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export let dateField = 'date'
|
|
14
14
|
export let valueField = null
|
|
15
15
|
export let months = 12
|
|
16
|
-
export let colors = [transparent, '#FB8C00']
|
|
16
|
+
export let colors = ['transparent', '#FB8C00']
|
|
17
17
|
export let padding = 8
|
|
18
18
|
export let space = 2
|
|
19
19
|
export let size = 10
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { clamp } from 'yootils'
|
|
3
|
+
import Symbol from '../chart/Symbol.svelte'
|
|
4
|
+
import { getContext } from 'svelte'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const chart = getContext('chart')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export let size = 8
|
|
9
|
+
export let fill = '#c0c0c0'
|
|
10
|
+
export let stroke = '#3c3c3c'
|
|
11
|
+
export let jitterWidth = 50
|
|
12
|
+
export let offset
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
$: jitterWidth = clamp(jitterWidth, 0, 100 / 2)
|
|
15
|
+
$: offset = clamp(offset | (jitterWidth / 2), 0, 100)
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
{#if $chart.data}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
{#each $chart.data as d}
|
|
20
|
+
<Symbol
|
|
21
|
+
x={$chart.axis.x.scale(d[$chart.x]) -
|
|
22
|
+
offset +
|
|
23
|
+
Math.random() * jitterWidth}
|
|
24
|
+
y={$chart.axis.y.scale(d[$chart.y])}
|
|
25
|
+
{fill}
|
|
26
|
+
{stroke}
|
|
27
|
+
{size}
|
|
28
|
+
/>
|
|
29
|
+
{/each}
|
|
30
30
|
{/if}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let chart = getContext('chart')
|
|
5
|
+
$: data = $chart.violin()
|
|
6
|
+
// $: console.log(data)
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
|
-
{#each data as { x, curve }
|
|
10
|
-
|
|
9
|
+
{#each data as { x, curve }}
|
|
10
|
+
<path d={curve} transform="translate({x},0)" fill="gray" stroke="none" />
|
|
11
11
|
{/each}
|
package/src/plots/heatmap.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
endOfWeek
|
|
11
11
|
} from 'date-fns'
|
|
12
12
|
import { nest } from 'd3-collection'
|
|
13
|
-
import { group } from 'd3-array'
|
|
13
|
+
// import { group } from 'd3-array'
|
|
14
14
|
|
|
15
15
|
const DATE_FORMAT = 'yyyy-MM-dd'
|
|
16
16
|
const weekdays = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']
|
package/src/lib/timer.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { writable } from 'svelte/store'
|
|
2
|
-
|
|
3
|
-
let req
|
|
4
|
-
let prev
|
|
5
|
-
const elapsed = writable(0)
|
|
6
|
-
|
|
7
|
-
const tick = (timestamp) => {
|
|
8
|
-
if (!prev) prev = timestamp
|
|
9
|
-
const diff = Math.round(timestamp - prev)
|
|
10
|
-
|
|
11
|
-
if (diff > 0) {
|
|
12
|
-
prev = timestamp
|
|
13
|
-
}
|
|
14
|
-
elapsed.update((e) => e + diff)
|
|
15
|
-
req = window.requestAnimationFrame(tick)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const timer = {
|
|
19
|
-
start() {
|
|
20
|
-
if (typeof window === 'undefined') return
|
|
21
|
-
else if (!req) {
|
|
22
|
-
prev = null
|
|
23
|
-
req = window.requestAnimationFrame(tick)
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
stop() {
|
|
27
|
-
if (typeof window === 'undefined') return
|
|
28
|
-
else if (req) {
|
|
29
|
-
window.cancelAnimationFrame(req)
|
|
30
|
-
req = null
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
toggle() {
|
|
34
|
-
req ? timer.stop() : timer.start()
|
|
35
|
-
},
|
|
36
|
-
set(val) {
|
|
37
|
-
if (typeof val === 'number') elapsed.set(val)
|
|
38
|
-
},
|
|
39
|
-
reset() {
|
|
40
|
-
timer.set(0)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { timer, elapsed }
|