@johnmorrisdotca/dougu-sports 0.13.0 → 0.14.0
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/CHANGELOG.md +14 -0
- package/README.md +37 -24
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/turn-control.d.ts +13 -0
- package/dist/turn-control.js +15 -2
- package/dist/turn-entry.d.ts +2 -2
- package/dist/turn-entry.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ All notable changes to this project are written here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.14.0] - 2026-10-21
|
|
10
|
+
|
|
11
|
+
The auto-turn can go either way, and the pictures and the demo are slower and wait for the pointer.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`direction` for the auto-turn**: `bindTurn(container, emblem, { direction: "clockwise" })` (seen from above; the default, `"counterclockwise"`, is how it has always turned, the front swinging to the viewer's right). `controller.setDirection(direction)` changes it while it turns without stopping it, `controller.direction()` reads it, and `turnDirection(value)` is the check the option goes through (exported from `./turn` and the main entry, with the `TurnDirection` type). `update` keeps the direction unless it names one. A drag, the keys and `setAngles` are not reversed. Tests: `test/turn-control.test.ts` and the demo's.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **README: it opens on the still pictures again** (the balls, the vintage balls, the trophies, the famous trophies and the gear, with the turned and phone pictures), as before 0.12.1. The turning pictures sit lower, each beside its own point of "The best of it" (the famous trophies, the balls, the medals and crests), never stacked.
|
|
20
|
+
- **The turning pictures run at half the speed** (`pnpm animations` shows each frame 140 ms, it was 70; `DELAY=70` for the old pace).
|
|
21
|
+
- **Demo: the emblem waits still and turns while the mouse is over it.** Leaving stops it where it is; a tap on a phone turns it and a second tap holds it (a drag turns it by hand as before). Auto-turn keeps it going wherever the pointer is, and `?turn=1` starts it with the page. The speed buttons are Slow 9, Medium 18 (the default, half of the old 36) and Fast 45 degrees a second; addresses with `speed=18`, `36` or `90` still mean those speeds. A **Reverse** button (`逆回転`, "reverse rotation", with the label `逆向きに回す`, "Turn the other way") turns it the other way, kept in the address as `dir=cw`. The trophy case waits still too and turns an emblem while the pointer is over it or after a tap, at 22 degrees a second (it was 45). A reader who prefers reduced motion is never turned for by the pointer. The package's own default speed (36) is unchanged.
|
|
22
|
+
|
|
9
23
|
## [0.13.0] - 2026-10-20
|
|
10
24
|
|
|
11
25
|
Four combat sports get their pictograms, so a page that lists MMA, boxing, wrestling or professional wrestling no longer borrows the judo or karate suit.
|
package/README.md
CHANGED
|
@@ -15,29 +15,25 @@ The ball and the gear of every sport, trophies, medals, crests and the icon of e
|
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<picture>
|
|
18
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/
|
|
19
|
-
<img alt="
|
|
18
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/balls-desk-dark.webp">
|
|
19
|
+
<img alt="Thirty-six balls and pucks drawn in 3D under floodlights, in four rows of nine: soccer balls of several constructions and colours, then basketball, the 3x3 ball, baseball, softball, a football, a rugby ball, an Australian football and two volleyballs, then tennis, padel, pickleball with its holes, squash with its two dots, racquetball, golf, red and pink cricket and water polo, and last sepak takraw, a shuttlecock, a puck, a curling stone, lacrosse, handball, table tennis, a sliotar and a roundnet ball." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/balls-desk-light.webp" width="760">
|
|
20
20
|
</picture>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
<p align="center">
|
|
24
24
|
<picture>
|
|
25
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/
|
|
26
|
-
<img alt="
|
|
25
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/vintage-desk-dark.webp">
|
|
26
|
+
<img alt="Eighteen more balls on a warm sunburst, in two rows of nine: five vintage leather soccer balls (hand-stitched, laced, 18 strips, 12 panels, 32 panels), a lemon-peel baseball, two baseballs stitched in two colours and an aged baseball, then nine soccer balls in the style of an era, with patterns of pentagons, leaves, a rosette, a star, a pinwheel and kites, a double border and plain white panels." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/vintage-desk-light.webp" width="760">
|
|
27
27
|
</picture>
|
|
28
28
|
</p>
|
|
29
29
|
|
|
30
30
|
<p align="center">
|
|
31
31
|
<picture>
|
|
32
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/
|
|
33
|
-
<img alt="
|
|
32
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/hero-desk-dark.webp">
|
|
33
|
+
<img alt="Trophies, medals and crests, in four rows of nine: nine famous cups, then a gilded cup, a phoenix-handle cup, a soccer ball trophy, a wreath, a rosette, a belt, a banner, a ring and a plaque, then three medals, three place badges and three crests, and last three cups each in metal, line and colour." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/hero-desk-light.webp" width="760">
|
|
34
34
|
</picture>
|
|
35
35
|
</p>
|
|
36
36
|
|
|
37
|
-
## The best of it
|
|
38
|
-
|
|
39
|
-
- **47 famous trophies**, each a close likeness measured on a photograph and carrying no lettering, logo or mark: the Stanley Cup, the FIFA World Cup, the Lombardi Trophy, the Larry O'Brien trophy, the Grey Cup and the rest ([famous trophies](./docs/famous-trophies.md)).
|
|
40
|
-
|
|
41
37
|
<p align="center">
|
|
42
38
|
<picture>
|
|
43
39
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/famous-desk-dark.webp">
|
|
@@ -45,41 +41,57 @@ The ball and the gear of every sport, trophies, medals, crests and the icon of e
|
|
|
45
41
|
</picture>
|
|
46
42
|
</p>
|
|
47
43
|
|
|
48
|
-
- **117 balls and implements in 3D**, from the 32-panel soccer ball to the pucks and the curling stone, that roll as they turn ([gallery](./docs/gallery.md), [vintage and era-style balls](./docs/vintage-balls.md)).
|
|
49
|
-
|
|
50
44
|
<p align="center">
|
|
51
45
|
<picture>
|
|
52
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/
|
|
53
|
-
<img alt="Thirty-six
|
|
46
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/gear-desk-dark.webp">
|
|
47
|
+
<img alt="Thirty-six pieces of gear in four rows of nine: hockey stick and skate, a goalie mask, field hockey, lacrosse and hurling sticks, a cricket bat and wicket, a baseball bat and glove, a football helmet and goalposts, a basketball hoop, a volleyball net, rackets and paddles, a curling broom, skates, swim goggles, starting blocks, a baton, a javelin, a hurdle, and the kendo, sumo, judo, kyudo and karate gear of Japan." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/gear-desk-light.webp" width="760">
|
|
54
48
|
</picture>
|
|
55
49
|
</p>
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
<table align="center">
|
|
52
|
+
<tr>
|
|
53
|
+
<td align="center" valign="top">
|
|
54
|
+
<img alt="A two-handled cup, a medal, a soccer ball and a championship banner each turned through seven angles: the cup keeps its outline and moves its light and handles, the medal and the banner flip like a coin to show their plain backs, and the ball rolls." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/turn-desk.webp" width="470"><br><em>Turned: a ball rolls, a medal flips</em>
|
|
55
|
+
</td>
|
|
56
|
+
<td align="center" valign="top">
|
|
57
|
+
<img alt="Cups, a medal, balls and gear on a phone, three to a row." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/phone-light.webp" width="200"><br><em>On a phone</em>
|
|
58
|
+
</td>
|
|
59
|
+
</tr>
|
|
60
|
+
</table>
|
|
61
|
+
|
|
62
|
+
## The best of it
|
|
63
|
+
|
|
64
|
+
- **47 famous trophies**, each a close likeness measured on a photograph and carrying no lettering, logo or mark: the Stanley Cup, the FIFA World Cup, the Lombardi Trophy, the Larry O'Brien trophy, the Grey Cup and the rest ([famous trophies](./docs/famous-trophies.md)).
|
|
58
65
|
|
|
59
66
|
<p align="center">
|
|
60
67
|
<picture>
|
|
61
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/
|
|
62
|
-
<img alt="
|
|
68
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/trophies-turn-dark.webp">
|
|
69
|
+
<img alt="Five famous trophies turning in 3D on royal purple, each a little behind the one before: the Stanley Cup first, then the FIFA World Cup, the Lombardi Trophy, the Larry O'Brien trophy and the Webb Ellis Cup. Each keeps its outline while its light and its handles move." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/trophies-turn-light.webp" width="760">
|
|
63
70
|
</picture>
|
|
64
71
|
</p>
|
|
65
72
|
|
|
66
|
-
- **
|
|
73
|
+
- **117 balls and implements in 3D**, from the 32-panel soccer ball to the pucks and the curling stone, that roll as they turn ([gallery](./docs/gallery.md), [vintage and era-style balls](./docs/vintage-balls.md)).
|
|
67
74
|
|
|
68
75
|
<p align="center">
|
|
69
76
|
<picture>
|
|
70
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/
|
|
71
|
-
<img alt="
|
|
77
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/balls-turn-dark.webp">
|
|
78
|
+
<img alt="Seven balls rolling under floodlights: a soccer ball, a basketball, a baseball, a rugby ball, a volleyball, a tennis ball and a golf ball, each turned a little differently so that the seams and panels travel across them." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/balls-turn-light.webp" width="760">
|
|
72
79
|
</picture>
|
|
73
80
|
</p>
|
|
74
81
|
|
|
75
|
-
- **
|
|
82
|
+
- **Trophies, medals, crests and the icon of every sport**, in metal, one line or flat colour, light and dark.
|
|
76
83
|
|
|
77
84
|
<p align="center">
|
|
78
85
|
<picture>
|
|
79
|
-
<
|
|
86
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/flips-turn-dark.webp">
|
|
87
|
+
<img alt="A gold and a silver medal, a championship banner, a crest, a hockey skate and a baseball glove flipping like coins on royal purple: each shows its face, then its edge, then its plain back." src="https://raw.githubusercontent.com/johnmorrisdotca/dougu-sports/main/docs/images/flips-turn-light.webp" width="760">
|
|
80
88
|
</picture>
|
|
81
89
|
</p>
|
|
82
90
|
|
|
91
|
+
- **70 pieces of gear**, among them the Japanese sports and budo ([Japanese sports](./docs/japanese-sports.md)).
|
|
92
|
+
|
|
93
|
+
- **On a phone**, and **turned by hand**: drag, arrow keys or the automatic turn ([turning](./docs/turning.md)).
|
|
94
|
+
|
|
83
95
|
> **Status: preview.** 325 emblems: 71 trophies, 6 awards, 6 medals, 4 crests, a pictogram for each of the 42 sports, 117 balls and implements drawn in 3D, 8 printed pucks ([docs/pucks.md](./docs/pucks.md)), 70 pieces of gear (among them the Japanese sports and budo, [docs/japanese-sports.md](./docs/japanese-sports.md)) and a championship pennant; [docs/layout.md](./docs/layout.md) says where each goes. All of it is drawn for this package: no art is copied from another project.
|
|
84
96
|
|
|
85
97
|
## In 30 seconds
|
|
@@ -394,9 +406,10 @@ import { TROPHY_TENNIS_CUP } from "@johnmorrisdotca/dougu-sports/trophy/tennis-c
|
|
|
394
406
|
|
|
395
407
|
const turner = bindTurn(document.getElementById("cup"), TROPHY_TENNIS_CUP, { size: 160, speed: 36 });
|
|
396
408
|
document.getElementById("spin").onclick = () => turner.togglePlay();
|
|
409
|
+
turner.setDirection("clockwise"); // seen from above: the other way (the default, `"counterclockwise"`, swings the front to the viewer's right)
|
|
397
410
|
```
|
|
398
411
|
|
|
399
|
-
A drag turns it, the arrow keys turn it, Space starts and stops an auto-turn, and nothing moves until you ask. Pass the emblem itself and the page carries the turning and that one emblem and nothing else (a cup and the turning are about 9 kB gzipped); pass an id, `"trophy:tennis-cup"`, and the registry is loaded when it is needed. See [docs/turning.md](./docs/turning.md).
|
|
412
|
+
`direction` is `"counterclockwise"` (how it has always turned) or `"clockwise"`, and `turnDirection(value)` is the check it goes through (anything but `"clockwise"` is counterclockwise). A drag turns it, the arrow keys turn it, Space starts and stops an auto-turn, and nothing moves until you ask. Pass the emblem itself and the page carries the turning and that one emblem and nothing else (a cup and the turning are about 9 kB gzipped); pass an id, `"trophy:tennis-cup"`, and the registry is loaded when it is needed. See [docs/turning.md](./docs/turning.md).
|
|
400
413
|
|
|
401
414
|
### In React, Vue and the rest
|
|
402
415
|
|
|
@@ -645,7 +658,7 @@ Bug reports and ideas go in the [issues](https://github.com/johnmorrisdotca/doug
|
|
|
645
658
|
|
|
646
659
|
## Changes
|
|
647
660
|
|
|
648
|
-
See [CHANGELOG.md](./CHANGELOG.md). 0.13.0 adds a pictogram for each of four combat sports, MMA (a cage), boxing (a glove), wrestling (two wrestlers on the mat) and professional wrestling (a ring with ropes), in the three styles (325 emblems); 0.12.0 adds forty-seven named trophies, each a close likeness measured on a photograph (321 emblems); 0.11.0 gives the era soccer balls neutral ids (the old ones stay as aliases), new looks and a second 1980s ball (274 emblems); 0.10.0 adds a standalone ribbon and the nets and posts of sepak takraw, netball and teqball from their rulebooks' sizes (273 emblems); 0.9.0 lets the baseball, the softball and the classic soccer balls be painted and printed: solid and two-tone colours, a logo of your own wrapped onto the ball, stamped text, an original cursive word and a small mark, all turning with the ball ([docs/custom-balls.md](./docs/custom-balls.md)); 0.8.0 makes `bindTurn` light: it takes an emblem object and then needs no registry, so a turnable cup is about 9.4 kB gzipped instead of about 81 kB, and an id loads the registry on demand; 0.7.3 turns the build, docs and picture scripts, the browser tests and the demo's source from JavaScript into TypeScript, with no change to the package; 0.7.2 makes every docs page single-language (a page in Japanese beside each page that had Japanese words in it, and a test that holds them apart), with no change to the pictures; 0.7.1 puts real countries (Canada, Japan) in the crest and puck examples in place of made-up teams, with no change to the code; 0.7.0 gives the national volleyballs layouts that tell them apart (Japan a crimson band, Poland white above and red below, the USA a navy field), strengthens the 2010-style grooved soccer ball, and adds six pictures of how the judo belt is tied, `gear:obi-step-1` to `gear:obi-step-6` (269 emblems: [docs/obi-steps.md](./docs/obi-steps.md)); 0.6.0 gives the judo suit and the karate suit their sleeves (a judogi has no short ones: they reach the wrist) and adds the judogi seen from behind with the IJF-style back number, a family name and a country code on a patch, with a `backnumber` option (269 emblems: [docs/judogi-back.md](./docs/judogi-back.md)); 0.5.1 redraws the judo suit, the belt and the football pictograms and adds the blue and folded suits and the belts of every grade (261 emblems: [docs/japanese-sports.md](./docs/japanese-sports.md)); 0.5.0 adds fifty balls: vintage leather soccer balls, era-style and shop-wall soccer balls, baseballs of other threads and volleyballs in national colours, with a `colors` option (244 emblems: [docs/vintage-balls.md](./docs/vintage-balls.md)); 0.4.0 adds eight printed pucks and a `face` option (194 emblems: [docs/pucks.md](./docs/pucks.md)); 0.3.0 adds nineteen soccer balls (26, 18, 14, 12 and 6 panels, winter orange and high-visibility yellow, futsal and beach soccer: 186 emblems); 0.2.1 draws every ball and implement to the rulebook's proportions; 0.2.0 is 167 emblems, every one drawn here, with the Japanese sports, engraving, a turn for every emblem and the compose helpers; 0.1.0 brought the first full set of 148; 0.0.1 was the first preview.
|
|
661
|
+
See [CHANGELOG.md](./CHANGELOG.md). 0.14.0 lets the auto-turn go either way (`direction: "clockwise"` or `"counterclockwise"`, `setDirection()`); 0.13.0 adds a pictogram for each of four combat sports, MMA (a cage), boxing (a glove), wrestling (two wrestlers on the mat) and professional wrestling (a ring with ropes), in the three styles (325 emblems); 0.12.0 adds forty-seven named trophies, each a close likeness measured on a photograph (321 emblems); 0.11.0 gives the era soccer balls neutral ids (the old ones stay as aliases), new looks and a second 1980s ball (274 emblems); 0.10.0 adds a standalone ribbon and the nets and posts of sepak takraw, netball and teqball from their rulebooks' sizes (273 emblems); 0.9.0 lets the baseball, the softball and the classic soccer balls be painted and printed: solid and two-tone colours, a logo of your own wrapped onto the ball, stamped text, an original cursive word and a small mark, all turning with the ball ([docs/custom-balls.md](./docs/custom-balls.md)); 0.8.0 makes `bindTurn` light: it takes an emblem object and then needs no registry, so a turnable cup is about 9.4 kB gzipped instead of about 81 kB, and an id loads the registry on demand; 0.7.3 turns the build, docs and picture scripts, the browser tests and the demo's source from JavaScript into TypeScript, with no change to the package; 0.7.2 makes every docs page single-language (a page in Japanese beside each page that had Japanese words in it, and a test that holds them apart), with no change to the pictures; 0.7.1 puts real countries (Canada, Japan) in the crest and puck examples in place of made-up teams, with no change to the code; 0.7.0 gives the national volleyballs layouts that tell them apart (Japan a crimson band, Poland white above and red below, the USA a navy field), strengthens the 2010-style grooved soccer ball, and adds six pictures of how the judo belt is tied, `gear:obi-step-1` to `gear:obi-step-6` (269 emblems: [docs/obi-steps.md](./docs/obi-steps.md)); 0.6.0 gives the judo suit and the karate suit their sleeves (a judogi has no short ones: they reach the wrist) and adds the judogi seen from behind with the IJF-style back number, a family name and a country code on a patch, with a `backnumber` option (269 emblems: [docs/judogi-back.md](./docs/judogi-back.md)); 0.5.1 redraws the judo suit, the belt and the football pictograms and adds the blue and folded suits and the belts of every grade (261 emblems: [docs/japanese-sports.md](./docs/japanese-sports.md)); 0.5.0 adds fifty balls: vintage leather soccer balls, era-style and shop-wall soccer balls, baseballs of other threads and volleyballs in national colours, with a `colors` option (244 emblems: [docs/vintage-balls.md](./docs/vintage-balls.md)); 0.4.0 adds eight printed pucks and a `face` option (194 emblems: [docs/pucks.md](./docs/pucks.md)); 0.3.0 adds nineteen soccer balls (26, 18, 14, 12 and 6 panels, winter orange and high-visibility yellow, futsal and beach soccer: 186 emblems); 0.2.1 draws every ball and implement to the rulebook's proportions; 0.2.0 is 167 emblems, every one drawn here, with the Japanese sports, engraving, a turn for every emblem and the compose helpers; 0.1.0 brought the first full set of 148; 0.0.1 was the first preview.
|
|
649
662
|
|
|
650
663
|
## Credits
|
|
651
664
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from "./emblems-entry.ts";
|
|
2
2
|
export { ballFrame, emblemFrame } from "./emblems/emblem.api.ts";
|
|
3
3
|
export { bindTurn } from "./turn-full.ts";
|
|
4
|
-
export
|
|
4
|
+
export { turnDirection } from "./turn-control.ts";
|
|
5
|
+
export type { TurnAngles, TurnContainer, TurnControlOptions, TurnController, TurnDirection, TurnEvent } from "./turn-control.ts";
|
|
5
6
|
export { EMBLEM_TABLE } from "./emblems/emblem.registry.ts";
|
|
6
7
|
export { AWARD_MEDAL } from "./emblems/award/medal.ts";
|
|
7
8
|
export { AWARD_BADGE } from "./emblems/award/badge.ts";
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export * from "./emblems-entry.js";
|
|
4
4
|
export { ballFrame, emblemFrame } from "./emblems/emblem.api.js";
|
|
5
5
|
export { bindTurn } from "./turn-full.js";
|
|
6
|
+
export { turnDirection } from "./turn-control.js";
|
|
6
7
|
export { EMBLEM_TABLE } from "./emblems/emblem.registry.js";
|
|
7
8
|
export { AWARD_MEDAL } from "./emblems/award/medal.js";
|
|
8
9
|
export { AWARD_BADGE } from "./emblems/award/badge.js";
|
package/dist/turn-control.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ export interface TurnRegistry {
|
|
|
8
8
|
renderEmblem(ref: EmblemRef, options?: FrameOptions): string;
|
|
9
9
|
emblemFrame(ref: EmblemRef, options?: FrameOptions): string;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Which way the auto-turn goes, seen from above. `"counterclockwise"` is how it has always turned: the front swings to the viewer's right. `"clockwise"` is the other way: the front swings to the viewer's left.
|
|
13
|
+
* A drag, the arrow keys and `setAngles` are not reversed.
|
|
14
|
+
*/
|
|
15
|
+
export type TurnDirection = "clockwise" | "counterclockwise";
|
|
16
|
+
/** A direction from anything: `"clockwise"` is clockwise, and everything else is the default, `"counterclockwise"`. */
|
|
17
|
+
export declare function turnDirection(value: unknown): TurnDirection;
|
|
11
18
|
/** The three angles of a turn, in degrees. */
|
|
12
19
|
export interface TurnAngles {
|
|
13
20
|
/** About the vertical axis, from -180 (excluded) to 180. */
|
|
@@ -34,6 +41,8 @@ export interface TurnControlOptions extends FrameOptions {
|
|
|
34
41
|
autoPlay?: boolean | "force";
|
|
35
42
|
/** Degrees of yaw each second the auto-turn advances (36 by default; negative turns the other way). */
|
|
36
43
|
speed?: number;
|
|
44
|
+
/** Which way the auto-turn goes (`"counterclockwise"`, the way it has always turned, by default). `update` keeps the direction unless it names one; a negative `speed` reverses it. */
|
|
45
|
+
direction?: TurnDirection;
|
|
37
46
|
/** When true (the default), a drag holds the auto-turn while the pointer is down, and an arrow key, Home or `setAngles` pauses it. When false nothing but `pause()` stops it. */
|
|
38
47
|
pauseOnInteract?: boolean;
|
|
39
48
|
/** Called with `true` when the auto-turn starts and `false` when it stops, whatever stopped it. */
|
|
@@ -60,6 +69,10 @@ export interface TurnController {
|
|
|
60
69
|
play(): boolean;
|
|
61
70
|
/** Stops the auto-turn. */
|
|
62
71
|
pause(): void;
|
|
72
|
+
/** Which way the auto-turn goes. */
|
|
73
|
+
direction(): TurnDirection;
|
|
74
|
+
/** Changes which way the auto-turn goes, at once and without stopping it. */
|
|
75
|
+
setDirection(direction: TurnDirection): void;
|
|
63
76
|
/** Starts or stops the auto-turn and gives the new state; `false` for an emblem that cannot turn. */
|
|
64
77
|
togglePlay(): boolean;
|
|
65
78
|
/** Removes the listeners and the attributes and styles `bindTurn` added; the last drawing stays. */
|
package/dist/turn-control.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** A direction from anything: `"clockwise"` is clockwise, and everything else is the default, `"counterclockwise"`. */
|
|
2
|
+
export function turnDirection(value) {
|
|
3
|
+
return value === "clockwise" ? "clockwise" : "counterclockwise";
|
|
4
|
+
}
|
|
1
5
|
const WORDS = {
|
|
2
6
|
en: { role: "turnable emblem", hint: "Drag, or use the arrow keys, to turn it. Space starts and stops the turning." },
|
|
3
7
|
ja: { role: "回せるエンブレム", hint: "ドラッグするか矢印キーで回せます。スペースキーで自動回転を始めたり止めたりできます。" },
|
|
@@ -63,6 +67,7 @@ export function bindTurnWith(registry, container, ref, options = {}) {
|
|
|
63
67
|
let range = [-60, 60];
|
|
64
68
|
let keyStep = 5;
|
|
65
69
|
let speed = 36;
|
|
70
|
+
let way = turnDirection(options.direction);
|
|
66
71
|
let pauseOnInteract = true;
|
|
67
72
|
let locale = "en";
|
|
68
73
|
let onTurn;
|
|
@@ -86,12 +91,14 @@ export function bindTurnWith(registry, container, ref, options = {}) {
|
|
|
86
91
|
range = low <= high ? [low, high] : [high, low];
|
|
87
92
|
keyStep = clamp(finite(o.keyStep, 5), 0.5, 90);
|
|
88
93
|
speed = clamp(finite(o.speed, 36), -720, 720);
|
|
94
|
+
if (o.direction !== undefined)
|
|
95
|
+
way = turnDirection(o.direction);
|
|
89
96
|
pauseOnInteract = o.pauseOnInteract !== false;
|
|
90
97
|
locale = o.locale === "ja" ? "ja" : "en";
|
|
91
98
|
onTurn = typeof o.onTurn === "function" ? o.onTurn : undefined;
|
|
92
99
|
onPlayChange = typeof o.onPlayChange === "function" ? o.onPlayChange : undefined;
|
|
93
100
|
const rest = { ...o };
|
|
94
|
-
for (const name of ["sensitivity", "pitchRange", "keyStep", "onTurn", "autoPlay", "speed", "pauseOnInteract", "onPlayChange", "yaw", "pitch", "roll"])
|
|
101
|
+
for (const name of ["sensitivity", "pitchRange", "keyStep", "onTurn", "autoPlay", "speed", "direction", "pauseOnInteract", "onPlayChange", "yaw", "pitch", "roll"])
|
|
95
102
|
delete rest[name];
|
|
96
103
|
frame = rest;
|
|
97
104
|
};
|
|
@@ -156,7 +163,7 @@ export function bindTurnWith(registry, container, ref, options = {}) {
|
|
|
156
163
|
const dt = last === undefined ? 0 : clamp((time - last) / 1000, 0, 0.1);
|
|
157
164
|
last = time;
|
|
158
165
|
if (!held && dt > 0) {
|
|
159
|
-
place({ yaw: angles.yaw + speed * dt });
|
|
166
|
+
place({ yaw: angles.yaw + (way === "clockwise" ? -1 : 1) * speed * dt });
|
|
160
167
|
draw();
|
|
161
168
|
onTurn?.(copy());
|
|
162
169
|
}
|
|
@@ -378,6 +385,12 @@ export function bindTurnWith(registry, container, ref, options = {}) {
|
|
|
378
385
|
if (pending === undefined)
|
|
379
386
|
draw();
|
|
380
387
|
},
|
|
388
|
+
direction() {
|
|
389
|
+
return way;
|
|
390
|
+
},
|
|
391
|
+
setDirection(next) {
|
|
392
|
+
way = turnDirection(next);
|
|
393
|
+
},
|
|
381
394
|
play() {
|
|
382
395
|
if (!turnable || destroyed)
|
|
383
396
|
return false;
|
package/dist/turn-entry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ballFrame, emblemFrame } from "./emblems/emblem.api.ts";
|
|
2
2
|
export type { FrameOptions } from "./emblems/emblem.core.ts";
|
|
3
|
-
export { bindTurn } from "./turn-control.ts";
|
|
4
|
-
export type { TurnAngles, TurnContainer, TurnControlOptions, TurnController, TurnEvent } from "./turn-control.ts";
|
|
3
|
+
export { bindTurn, turnDirection } from "./turn-control.ts";
|
|
4
|
+
export type { TurnAngles, TurnContainer, TurnControlOptions, TurnController, TurnDirection, TurnEvent } from "./turn-control.ts";
|
package/dist/turn-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// The turning entry point: an emblem at an angle. `emblemFrame` turns any emblem about its vertical axis and tilts it; `ballFrame` rolls a ball. Each frame is plain SVG, so a turn is a loop over
|
|
2
2
|
// the angle, drawn by the caller (a slider, a requestAnimationFrame, a CSS-free animation).
|
|
3
3
|
export { ballFrame, emblemFrame } from "./emblems/emblem.api.js";
|
|
4
|
-
export { bindTurn } from "./turn-control.js";
|
|
4
|
+
export { bindTurn, turnDirection } from "./turn-control.js";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.14.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.14.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/dougu-sports",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Dougu Sports 道具, sports emblems as SVG strings: trophies, medals, crests, sport icons, and the ball and gear of every sport, in metal, line or flat colour, with optional 3D turning. Light and dark, accessible, tree-shakeable. Zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sports",
|