Skip to content

Commit d1ed27a

Browse files
authored
Merge pull request #94 from peterhry/force-width
Implement forceWidth and forceHeight options
2 parents 426a0e3 + 9b48c9c commit d1ed27a

File tree

9 files changed

+1057
-63
lines changed

9 files changed

+1057
-63
lines changed

README.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
A JavaScript library that lets you curve type on the web.
66

7-
Demo: <http://circletype.labwire.ca>
7+
Demo: <https://circletype.labwire.ca>
88

99
## Installation
1010

README.md

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
A JavaScript library that lets you curve type on the web.
66

7-
Demo: <http://circletype.labwire.ca>
7+
Demo: <https://circletype.labwire.ca>
88

99
## Installation
1010

@@ -39,6 +39,10 @@ A CircleType instance creates a circular text element.
3939
* [.radius()](#CircleType+radius) ⇒ <code>number</code>
4040
* [.dir(value)](#CircleType+dir)[<code>CircleType</code>](#CircleType)
4141
* [.dir()](#CircleType+dir) ⇒ <code>number</code>
42+
* [.forceWidth(value)](#CircleType+forceWidth)[<code>CircleType</code>](#CircleType)
43+
* [.forceWidth()](#CircleType+forceWidth) ⇒ <code>boolean</code>
44+
* [.forceHeight(value)](#CircleType+forceHeight)[<code>CircleType</code>](#CircleType)
45+
* [.forceHeight()](#CircleType+forceHeight) ⇒ <code>boolean</code>
4246
* [.refresh()](#CircleType+refresh)[<code>CircleType</code>](#CircleType)
4347
* [.destroy()](#CircleType+destroy)[<code>CircleType</code>](#CircleType)
4448

@@ -92,7 +96,7 @@ for the text to form a complete circle.
9296
const circleType = new CircleType(document.getElementById('myElement'));
9397

9498
circleType.radius();
95-
// > 150
99+
//=> 150
96100
```
97101
<a name="CircleType+dir"></a>
98102

@@ -128,7 +132,93 @@ Gets the text direction. `1` is clockwise, `-1` is counter-clockwise.
128132
const circleType = new CircleType(document.getElementById('myElement'));
129133

130134
circleType.dir();
131-
// > 1 (clockwise)
135+
//=> 1 (clockwise)
136+
```
137+
<a name="CircleType+forceWidth"></a>
138+
139+
### circleType.forceWidth(value) ⇒ [<code>CircleType</code>](#CircleType)
140+
Sets the `forceWidth` option. If `true` the width of the arc is calculated
141+
and applied to the element as an inline style.
142+
143+
**Kind**: instance method of [<code>CircleType</code>](#CircleType)
144+
**Returns**: [<code>CircleType</code>](#CircleType) - The current instance.
145+
146+
| Param | Type | Description |
147+
| --- | --- | --- |
148+
| value | <code>boolean</code> | `true` if the width should be set |
149+
150+
**Example**
151+
```js
152+
const circleType = new CircleType(document.getElementById('myElement'));
153+
154+
circleType.radius(384);
155+
156+
console.log(circleType.container);
157+
//=> <div style="position: relative; height: 3.18275em;">...</div>
158+
159+
// Enable the force width option
160+
circleType.forceWidth(true);
161+
162+
console.log(circleType.container);
163+
//=> <div style="position: relative; height: 3.18275em; width: 12.7473em;">...</div>
164+
```
165+
<a name="CircleType+forceWidth"></a>
166+
167+
### circleType.forceWidth() ⇒ <code>boolean</code>
168+
Gets the `forceWidth` option. If `true` the width of the arc is calculated
169+
and applied to the element as an inline style. Defaults to `false`.
170+
171+
**Kind**: instance method of [<code>CircleType</code>](#CircleType)
172+
**Returns**: <code>boolean</code> - The current `forceWidth` value
173+
**Example**
174+
```js
175+
const circleType = new CircleType(document.getElementById('myElement'));
176+
177+
circleType.forceWidth();
178+
//=> false
179+
```
180+
<a name="CircleType+forceHeight"></a>
181+
182+
### circleType.forceHeight(value) ⇒ [<code>CircleType</code>](#CircleType)
183+
Sets the `forceHeight` option. If `true` the height of the arc is calculated
184+
and applied to the element as an inline style.
185+
186+
**Kind**: instance method of [<code>CircleType</code>](#CircleType)
187+
**Returns**: [<code>CircleType</code>](#CircleType) - The current instance.
188+
189+
| Param | Type | Description |
190+
| --- | --- | --- |
191+
| value | <code>boolean</code> | `true` if the height should be set |
192+
193+
**Example**
194+
```js
195+
const circleType = new CircleType(document.getElementById('myElement'));
196+
197+
circleType.radius(384);
198+
199+
console.log(circleType.container);
200+
//=> <div style="position: relative; height: 3.18275em;">...</div>
201+
202+
// Disable the force height option
203+
circleType.forceHeight(false);
204+
205+
console.log(circleType.container);
206+
//=> <div style="position: relative;">...</div>
207+
```
208+
<a name="CircleType+forceHeight"></a>
209+
210+
### circleType.forceHeight() ⇒ <code>boolean</code>
211+
Gets the `forceHeight` option. If `true` the height of the arc is calculated
212+
and applied to the element as an inline style. Defaults to `true`.
213+
214+
**Kind**: instance method of [<code>CircleType</code>](#CircleType)
215+
**Returns**: <code>boolean</code> - The current `forceHeight` value
216+
**Example**
217+
```js
218+
const circleType = new CircleType(document.getElementById('myElement'));
219+
220+
circleType.forceHeight();
221+
//=> true
132222
```
133223
<a name="CircleType+refresh"></a>
134224

assets/stylesheets/screen.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ footer {
139139

140140
.demo {
141141
color: #ff3300;
142+
display:flex;
143+
justify-content: center;
142144
margin: 0;
143-
text-align: center;
144145
}
145146

146147
/**

dist/circletype.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "circletype",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "A JavaScript library that lets you curve type on the web.",
55
"main": "dist/circletype.min.js",
66
"files": [
@@ -10,11 +10,11 @@
1010
"scripts": {
1111
"dev": "webpack-dev-server --open",
1212
"start": "eslint src && npm t && npm run docs && webpack -p",
13-
"test": "jest src --notify && docker run -w /usr/data -v \"$PWD\":/usr/data tenjaa/java-chrome-nodejs npm run backstop-test",
13+
"test": "jest src --notify && webpack -p && docker run -w /usr/data -v \"$PWD\":/usr/data tenjaa/java-chrome-nodejs npm run backstop-test",
1414
"reference": "docker run -w /usr/data -v \"$PWD\":/usr/data tenjaa/java-chrome-nodejs npm run backstop-reference",
1515
"backstop-test": "backstop test",
1616
"backstop-reference": "backstop reference",
17-
"docs": "jsdoc2md --template README.hbs --files src/class.js > README.md"
17+
"docs": "jsdoc2md --heading-depth 2 --template README.hbs --files src/class.js > README.md"
1818
},
1919
"keywords": [
2020
"circletype",

0 commit comments

Comments
 (0)