aboutsummaryrefslogtreecommitdiffstats
path: root/src/arrange.js
diff options
context:
space:
mode:
authorSaivan <savian@me.com>2018-02-27 00:48:11 +1100
committerSaivan <savian@me.com>2018-02-27 00:48:11 +1100
commitbec7881979149425a9c1b894f4741413b28c8141 (patch)
tree3a496f834520925686af3a8059766b61b65be390 /src/arrange.js
parentec0a8aee0e21a93b22c255dae6768a9ff7b09e73 (diff)
downloadsvg.js-bec7881979149425a9c1b894f4741413b28c8141.tar.gz
svg.js-bec7881979149425a9c1b894f4741413b28c8141.zip
The first half of the library complies with Standard linting
This commit reformats the code so that it complies with the standard linting style. Its currently a work in progress, but it is meant to pave the way for linting in the build process
Diffstat (limited to 'src/arrange.js')
-rw-r--r--src/arrange.js74
1 files changed, 43 insertions, 31 deletions
diff --git a/src/arrange.js b/src/arrange.js
index 15d3d3c..a908143 100644
--- a/src/arrange.js
+++ b/src/arrange.js
@@ -3,83 +3,95 @@
//
SVG.extend(SVG.Element, {
// Get all siblings, including myself
- siblings: function() {
+ siblings: function () {
return this.parent().children()
- }
+ },
+
// Get the curent position siblings
-, position: function() {
+ position: function () {
return this.parent().index(this)
- }
+ },
+
// Get the next element (will return null if there is none)
-, next: function() {
+ next: function () {
return this.siblings()[this.position() + 1]
- }
+ },
+
// Get the next element (will return null if there is none)
-, prev: function() {
+ prev: function () {
return this.siblings()[this.position() - 1]
- }
+ },
+
// Send given element one step forward
-, forward: function() {
+ forward: function () {
var i = this.position() + 1
- , p = this.parent()
+ var p = this.parent()
// move node one step forward
p.removeElement(this).add(this, i)
// make sure defs node is always at the top
- if (p instanceof SVG.Doc)
+ if (p instanceof SVG.Doc) {
p.node.appendChild(p.defs().node)
+ }
return this
- }
+ },
+
// Send given element one step backward
-, backward: function() {
+ backward: function () {
var i = this.position()
-
- if (i > 0)
+
+ if (i > 0) {
this.parent().removeElement(this).add(this, i - 1)
+ }
return this
- }
+ },
+
// Send given element all the way to the front
-, front: function() {
+ front: function () {
var p = this.parent()
// Move node forward
p.node.appendChild(this.node)
// Make sure defs node is always at the top
- if (p instanceof SVG.Doc)
+ if (p instanceof SVG.Doc) {
p.node.appendChild(p.defs().node)
+ }
return this
- }
+ },
+
// Send given element all the way to the back
-, back: function() {
- if (this.position() > 0)
+ back: function () {
+ if (this.position() > 0) {
this.parent().removeElement(this).add(this, 0)
-
+ }
+
return this
- }
+ },
+
// Inserts a given element before the targeted element
-, before: function(element) {
+ before: function (element) {
element.remove()
var i = this.position()
-
+
this.parent().add(element, i)
return this
- }
+ },
+
// Insters a given element after the targeted element
-, after: function(element) {
+ after: function (element) {
element.remove()
-
+
var i = this.position()
-
+
this.parent().add(element, i + 1)
return this
}
-
-}) \ No newline at end of file
+})