Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Note: setting a property to `undefined` will reset it to the default value.

Name | Default Value | Description
------------------------------- | ------------------| ---------------------------
`align` | `center` | The vertical alignment of the wheel within its container.</p><p>Possible values: `'top'`,`'center'`,`'bottom'`.
`borderColor` | `'#000'` | The [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) for the line around the circumference of the wheel.
`borderWidth` | `0` | The width (in pixels) of the line around the circumference of the wheel.
`debug` | `false` | If debugging info will be shown.</p><p>This is helpful when positioning labels.
Expand Down
10 changes: 10 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ export const baseCanvasSize = 500; // 500 seemed to be a good value for this.
*/
export const dragCapturePeriod = 250;

/**
* Wheel vertical alignment enum.
*/
export const AlignWheel = Object.freeze({
top: 'top',
center: 'center',
bottom: 'bottom',
});

/**
* Text alignment enum.
*/
Expand All @@ -27,6 +36,7 @@ export const AlignText = Object.freeze({
*/
export const Defaults = Object.freeze({
wheel: {
align: AlignWheel.center,
borderColor: '#000',
borderWidth: 1,
debug: false,
Expand Down
7 changes: 7 additions & 0 deletions src/wheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class Wheel {
init(props = {}) {
this._isInitialising = true;

this.align = props.align;
this.borderColor = props.borderColor;
this.borderWidth = props.borderWidth;
this.debug = props.debug;
Expand Down Expand Up @@ -146,6 +147,12 @@ export class Wheel {
y: h / 2 + (h * this._offset.y),
};

if (this.align === 'top') {
this._center.y = this._size / 2;
} else if (this.align === 'bottom') {
this._center.y += this._size / 2;
}

// Calculate the wheel radius:
this._actualRadius = (this._size / 2) * this.radius;

Expand Down