Skip to content

Commit f3bfffb

Browse files
committed
first commit
0 parents  commit f3bfffb

File tree

8 files changed

+539
-0
lines changed

8 files changed

+539
-0
lines changed

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Denote all files that are truly binary and should not be modified.
5+
*.png binary
6+
*.jpg binary
7+
*.gif binary

.jshintrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"browser": true,
3+
"jquery": false,
4+
"bitwise": true,
5+
"camelcase": true,
6+
"curly": false,
7+
"eqeqeq": true,
8+
"es3": true,
9+
"immed": true,
10+
"indent": 4,
11+
"latedef": true,
12+
"newcap": true,
13+
"nonbsp": true,
14+
"quotmark": "single",
15+
"undef": true,
16+
"unused": true,
17+
"strict": true,
18+
"trailing": true
19+
}

README.md

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
html-lines
2+
==========
3+
4+
Draw a line using an HTML element between two existing elements. Lines can easily be made to work responsively when attaching the `redraw` method to the window.resize event. Use CSS to control line styles and animation. Use the LINES API to manipulate the lines.
5+
6+
LINES
7+
-----
8+
This is the global object created when loading html-lines.js.
9+
```html
10+
<script src="html-lines.js"></script>
11+
```
12+
13+
If using CommonJS, **LINES** would be created by requiring.
14+
```js
15+
var LINES = require('html-lines');
16+
```
17+
18+
### LINES.setOptions
19+
@param - {Object}
20+
Change the default options.
21+
```js
22+
LINES.setOptions({
23+
lineElementType: {String},
24+
nameAttribute: {String},
25+
stateAttribute: {String}
26+
});
27+
28+
// defaults
29+
{
30+
lineElementType: 'div',
31+
nameAttribute: 'data-line',
32+
stateAttribute: 'data-line-state'
33+
}
34+
```
35+
36+
### LINES.createAnchor
37+
@param - {Object}
38+
@return - {Object} instance of Anchor
39+
```js
40+
var anchor = LINES.createAnchor({
41+
el: {HTMLElement or querySelector String},
42+
xOffset: {Number},
43+
yOffset: {Number},
44+
xOrigin: {'center' or 'left' or 'right'},
45+
yOrigin: {'center' or 'top' or 'left'}
46+
})
47+
48+
// defaults
49+
{
50+
el: document.body,
51+
xOffset: 0,
52+
yOffset: 0,
53+
xOrigin: 'center',
54+
yOrigin: 'center'
55+
}
56+
```
57+
*Anchors don't add anything to the DOM.*
58+
59+
### LINES.createLine
60+
@param - {Object} instance of Anchor
61+
@param - {Object} instance of Anchor
62+
@param - {Object}
63+
@return - {Object} instance of Line
64+
```js
65+
LINES.createLine(anchor1, anchor2, {
66+
name: {String},
67+
state: {String}
68+
})
69+
70+
// defaults
71+
{
72+
name: '',
73+
state: ''
74+
}
75+
```
76+
77+
### LINES.redraw
78+
Recalculates anchor positions and changes line position and size and angle
79+
```js
80+
LINES.redraw();
81+
```
82+
83+
### LINES.getAnchors
84+
@return - {Array}
85+
```js
86+
var anchors = LINES.getAnchors();
87+
```
88+
89+
### LINES.getLines
90+
@return - {Array}
91+
```js
92+
var lines = LINES.getLines();
93+
```
94+
95+
### LINES.destroyAll
96+
```js
97+
LINES.destroyAll();
98+
```
99+
100+
Instance of Anchor
101+
------------------
102+
103+
```js
104+
var anchor = LINES.createAnchor(...);
105+
```
106+
107+
### anchor.destory
108+
```js
109+
anchor.destory();
110+
```
111+
*Any lines attached to this anchor will also be destoryed.*
112+
113+
Instance of Line
114+
----------------
115+
116+
```js
117+
var line = LINES.createLine(...);
118+
```
119+
120+
### line.name
121+
@param - {String}
122+
@return - {String}
123+
```js
124+
line.name('newName');
125+
// or
126+
var name = line.name(); // newName
127+
```
128+
129+
### line.state
130+
@param - {String}
131+
@return - {String}
132+
```js
133+
line.state('newState');
134+
// or
135+
var state = line.state(); // newState
136+
```
137+
138+
### line.destory
139+
```js
140+
line.destory();
141+
```

html-lines.css

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[data-line] {
2+
position: absolute;
3+
height: 1px;
4+
background: rgba(0, 0, 0, .8);
5+
transform-origin: left top;
6+
}
7+
8+
[data-line]::before {
9+
content: "";
10+
position: absolute;
11+
left: -1px;
12+
top: -1px;
13+
width: 3px;
14+
height: 3px;
15+
border-radius: 50%;
16+
background: rgba(0, 0, 0, .8);
17+
}
18+
19+
[data-line]::after {
20+
content: "";
21+
position: absolute;
22+
right: -1px;
23+
top: -1px;
24+
width: 3px;
25+
height: 3px;
26+
border-radius: 50%;
27+
background: rgba(0, 0, 0, .8);
28+
}

0 commit comments

Comments
 (0)