Repository navigation
v3.0.0
What's Changed
A rewrite, with a new engine and API. Upgrading from v2 maps each v2 option to its replacement.
Breaking changes
useReward(target, effect, config?, options?)takes a ref or an element instead of an element id, and an imported effect (confetti,emoji,balloon) instead of a type name.balloonsis nowballoon.- Settings use physical units:
velocityin px/s,gravityin px/s²,dragper second andlifetimein milliseconds.elementCountiscount,elementSizeissize,emojiisemojis, andstartVelocityanddecayare replaced byvelocity,dragandgravity. fpsandpositionare removed.zIndexandonAnimationComplete(nowonComplete) are burst options, in the fourth argument.onClick={reward}starts the burst at the pointer.onClick={() => reward()}starts it at the element.- The effects were redesigned and look different. Balloons can no longer be popped.
- Bursts are skipped for people who prefer reduced motion, unless
respectReducedMotionisfalse. - React 18 or later. The package is ESM only.
Added
- A particle engine that draws with WebGL2, with a Canvas 2D fallback, on one canvas over the page, so nothing clips a burst. Particles move by time, so bursts look the same at any frame rate.
reward()returns the burst. Calls stack, andisAnimatingstays true until every burst has ended.rewardkeeps one identity, and each call uses the latest arguments.fire(effect, options)plays an effect without React. Its burst hascancel(),finishedandrenderer.setRenderer('auto' | 'webgl' | 'canvas').defineEffectfor custom effects, with the math helpers the built-in effects use.- A
seedoption, so a burst can be replayed exactly. - A site with every effect live and the docs: https://thedevelobear.github.io/react-rewards/
- Packages are published from GitHub Actions with npm provenance.
Commits
- v3: setup rstest + simple CI pipeline by @thedevelobear in #115
- docs: create v3 branches with --no-track, mark PR 3 merged by @thedevelobear in #116
- v3: atlas canvas by @thedevelobear in #117
- v3: fire confetti by @thedevelobear in #118
- v3: webgl renderer by @thedevelobear in #119
- v3: emoji / balloon effects by @thedevelobear in #120
- v3: use reward by @thedevelobear in #121
- v3: site shell scaffolding by @thedevelobear in #122
- v3: props code preview by @thedevelobear in #123
- v3: stress deploy by @thedevelobear in #124
- v3: docs release by @thedevelobear in #125
- v3: release by @thedevelobear in #126
- v3: site initial design by @thedevelobear in #127
- v3.0.0 upgrade by @thedevelobear in #114
- chore: docs and cleanup by @thedevelobear in #128
Full Changelog: v2.1.0...v3.0.0