Live Race
A race as it’s run: the field in its silks along a straightened track, the places gliding as runners pass, a line from the call, and the dividends on the line.
Usage
import { LiveRace } from '@wdzyi/ui';
<LiveRace
race={{ track: 'Kestrel Park', number: 5, distance: 1200, straight: 400, turn: 300 }}
runners={starters}
run={feed.metres}
wide={feed.offRail}
step={250}
result={result}
pick={{ number: 4, stake: 10, odds: 3.3 }}
/>Part of @wdzyi/ui. See setup to install it, or copy the code above.
Props
- raceLiveRaceRace
- The race: its track, its number on the day, its name, the distance in metres, and how long the home straight and the turn into it are, 400m and 300m unless it says. R5 at Kestrel Park, 1200m, by default.
- runnersLiveRaceRunner[]
- The starters: each with its saddlecloth number, name, jockey and barrier, and silks found from its name unless you give it some. Eight sample runners by default.
- runRecord<number, number>
- How far each runner has run, in metres from the start, by saddlecloth number: the live feed. Left out, or all at nought, the field is at the barriers. The first to reach the distance has won.
- wideRecord<number, number>
- How far each runner is off the rail, in horse widths, by saddlecloth number. Left out, a runner is placed by its barrier at the start and on the rail after it.
- stepnumber = 250
- How often the feed updates, in ms. Each runner eases from one position to the next over this long, at an even speed, so the field never stops between updates.
- callstring
- A line from the race caller, when you have one. Left out, the call is made from the running.
- resultLiveRacePlacing[]
- The placings once the result is in, first first: each with its Win and Place dividends for a dollar and its margin to the one before, such as 0.1L. The rest are placed in the order they last ran, with their margins worked out.
- pickLiveRacePick
- Your bet, a Win bet on a runner at a price, with its stake. Its runner is marked on the strip and in the places, and the result says what it returns.
- denseboolean = false
- The strip and the first three only, with smaller silks on the strip, for a small space.
- currencystring = 'AUD'
- The currency of the dividends, your stake and its return, written the Australian way.
- classNamestring
- Added to the race. It’s 640px wide at most, and narrows with the space it’s in.
Notes
- The track is drawn straightened, the start on the left, the post on the right and the rail along the top, with the turn and the straight as flat tones a step apart. Each runner is its silks, placed by how far it has run and how far off the rail it is. The gaps are drawn larger than life, a length to a set of silks, so half a length can be read.
- Feed it positions as often as you have them and say how often with step: each runner eases from one to the next at an even speed, so the field never stops between updates. The places under it change hands as runners pass, each runner gliding to its new place over 380ms while the places stay where they are, and the head counts the metres to go beside a light that pings while they run.
- Without a call of your own, it makes one from the running: the jump, who shows the way, a new leader, round the turn, into the straight, a runner hitting the front, a tight finish inside the last 100m, and the winner. A runner has to lead by a tenth of a length before it’s called, so heads bobbing on the line don’t flick the call back and forth, and each new line rises in over 260ms.
- On the line the strip holds still and the post firms. The result then fills the columns kept for it from the start, the Win and Place dividends and the margins, with the places past third stepping back. With a pick, it says plainly what the bet returns in green, or that it doesn’t, without a fuss either way.
- It sends notify as they jump, the faintest tick as the lead changes hands, stop on the line, and win only when your pick wins and returns more than its stake, with settle otherwise. Each line of the call and the result are announced. With reduced motion, each runner takes its new position at once, the call changes in place and the light holds still.