Skip to content

Commit 630a0b6

Browse files
committed
chore(0.1.0): readme
1 parent fd29179 commit 630a0b6

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,74 @@ Do not use this, use [@mtmarco87](https://github.com/mtmarco87)'s package instea
55
Huge props to him for this TypeScript refactor !
66

77
No theme is shipped here, no docs either.
8+
9+
## What's changed ?
10+
For a quick overview in a real-world usage, see https://github.com/EDM115/website/blob/master/app/components/ui/Odometer.vue
11+
12+
- Removal of all built artifacts, themes, demo, screenshots and CoffeeScript code
13+
- Switch from Rollup to tsdown (Rolldown)
14+
- Added linting and formatting (OxLint + ESLint Stylistic)
15+
- Keep only the ESM build and switch to a default export
16+
- Better TS config and stricter types (no more `any` nor `as`)
17+
- Target ES2016 instead of ES2015
18+
- Remove compatibility layers (Internet Explorer, jQuery)
19+
- Stabilize and simplify the interfaces
20+
- Use overall more optimized methods
21+
- Renamed from `TmOdometer` to `LightOdometer`
22+
- No more const functions
23+
- SSR friendly (you can import it top-level without blowing up) and use safe fallbacks fror browser-land functions
24+
- Multiple performance improvements
25+
- `value` is now stripped from spaces
26+
- Each instance can now have an `id`
27+
- Ability to customize the framerate
28+
```ts
29+
const odo = new LightOdometer({ ..., framerate: 20 }) // default is 30, going above isn't recommended
30+
// use countFramerate if you use the `count` mode instead of `slide`
31+
```
32+
- Ability to render once and destroy the instance
33+
```ts
34+
const odo = new LightOdometer({ ..., value: 0 })
35+
odo.animateOnceAndDisconnect(12345)
36+
```
37+
- Expose `duration` as a CSS property to sync up JS and CSS animations
38+
```ts
39+
const odo = new LightOdometer({ ..., duration: 5000 })
40+
console.log(getComputedStyle(odo.el).getPropertyValue("--odometer-duration")) // "5000ms"
41+
```
42+
- Get and mutate instance and global options
43+
```ts
44+
const odo = new LightOdometer({ ... })
45+
console.log(odo.getOptions().duration)
46+
odo.setOptions({ duration: 2000 })
47+
48+
console.log(LightOdometer.getGlobalOptions.selector)
49+
LightOdometer.setGlobalOptions({ selector: ".my-odometer" })
50+
```
51+
- Add per-instance subscriptable animation start/end events. They give back the instance id, el, instance, value, oldValue, options
52+
```ts
53+
const odo = new LightOdometer({ ... })
54+
console.log(odo.isAnimating)
55+
56+
function onStart(e: Event) {
57+
const { detail } = e as CustomEvent<LightOdometerEventDetail>
58+
// detail.id, detail.value, detail.instance.isAnimating, ...
59+
console.log(`started animating to ${detail.value}`)
60+
}
61+
62+
function onDone(e: Event) {
63+
const { detail } = e as CustomEvent<LightOdometerEventDetail>
64+
console.log(`finished animating to ${detail.value}`)
65+
}
66+
67+
odo.on("odometerstart", onStart)
68+
odo.on("odometerdone", onDone)
69+
70+
// later
71+
odo.off("odometerstart", onStart)
72+
odo.off("odometerdone", onDone)
73+
```
74+
- Print the instance in a JSON-friendly string
75+
```ts
76+
const odo = new LightOdometer({ ... })
77+
console.log(odo.toString()) // {"id":2,"value":157,"options":{"id":2,"value":0,"animation":"slide","duration":8000,"format":"( ddd)","framerate":20},"globalOptions":{},"watchMutations":false,"transitionEndBound":true,"destroyed":false,"format":{"repeating":" ","precision":0},"isAnimating":false}
78+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@
7070
},
7171
"type": "module",
7272
"types": "./dist/main.d.ts",
73-
"version": "0.0.9"
73+
"version": "0.1.0"
7474
}

0 commit comments

Comments
 (0)