├── .github
└── FUNDING.yml
├── LICENSE
├── README.md
├── css
└── main.css
├── favicon.png
├── index.html
└── js
├── RotaryDial.js
└── main.js
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | patreon: victorqribeiro
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Victor Ribeiro
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Rotary Dial
2 |
3 | A [Rotary Dial](https://en.wikipedia.org/wiki/Rotary_dial) for input numbers.
4 |
5 | 
6 |
7 | Live version [here](https://victorribeiro.com/dial) | Alternative link [here](https://victorqribeiro.github.io/dial/index.html)
8 |
9 | # How to use it
10 |
11 | Click / Touch the disc and drag it until the arrow. When the number reaches the arrow, it will turn red, then let go and that's your number.
12 |
13 | # How to use it on your web app
14 |
15 | Include the RotaryDial.js file.
16 |
17 | ```html
18 |
19 | ```
20 |
21 | Then create a new RotaryDial
22 |
23 | ```javascript
24 | const rd = new RotaryDial();
25 | ```
26 |
27 | Creating a callback is easy, just define what your function will do with the number it receives from the RotaryDial.
28 |
29 | ```javascript
30 | const func = function(number){
31 | alert( number )
32 | }
33 |
34 | const rd = new RotaryDial({callback: func});
35 |
36 | ```
37 |
38 | By default the RotaryDial has the console.log function as the callback.
39 |
40 | # Documentation
41 |
42 | The RotaryDial accepts a configuration object on its constructor. The most import parts are the size and the callback. The size will determine the size of your rotary dial menu, and the callback determines which function will be called when a number is selected. Besides that, there are some color configurations you can fiddle with.
43 |
44 | **size** - The size of the menu. *Default 400px*
45 |
46 | **callback** - The function that will be called when a number is selected. *Default console.log*
47 |
48 | **discFillColor** - The disc color.
49 |
50 | **discStrokeColor** - The disc border color.
51 |
52 | **circlesFillColor** - The circles (where the numbers are displayed) color.
53 |
54 | **circlesStrokeColor** - The circles (where the numbers are displayed) border color.
55 |
56 | **circlesHighlightColor** - The color that a circle will be displayed when a number is selected.
57 |
58 | **textFillColor** - The text color.
59 |
60 | **textStrokeColor** - The text border color.
61 |
62 | **arrowFillColor** - The arrow color.
63 |
64 | **arrowStrokeColor** - The arrow border color.
65 |
--------------------------------------------------------------------------------
/css/main.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | height: 100%;
3 | margin: 0;
4 | padding: 0;
5 | display: flex;
6 | flex-direction: column;
7 | align-items: center;
8 | justify-content: space-around;
9 | }
10 |
11 | canvas {
12 | display: block;
13 | }
14 |
15 | input {
16 | width: 300px;
17 | height: 4em;
18 | padding-left: 0.5em;
19 | box-sizing: border-box;
20 | }
21 |
22 | button {
23 | width: 50px;
24 | height: 4em;
25 | margin-left: 0.5em;
26 | box-sizing: border-box;
27 | }
28 |
29 | @media only screen and (max-width: 600px) {
30 | canvas{
31 | width: 100%;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/victorqribeiro/dial/d3ff0ed2c7ceb8f047e28011e570de6223cc3e50/favicon.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |