summaryrefslogtreecommitdiffstats
path: root/src/arrange.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-06 13:48:05 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-06 13:48:05 +0100
commita0b13ebcacfd74b9f521110c7225bb404325bcd3 (patch)
treea07c5cc422645e31d7dfef81ce4e54f03f0945f6 /src/arrange.js
parent9f2696e8a2cf7e4eebc1cc7e31027fe2070094fa (diff)
downloadsvg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.tar.gz
svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.zip
reordered modules, add es6 build
Diffstat (limited to 'src/arrange.js')
-rw-r--r--src/arrange.js99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/arrange.js b/src/arrange.js
deleted file mode 100644
index 169cf93..0000000
--- a/src/arrange.js
+++ /dev/null
@@ -1,99 +0,0 @@
-// ### This module adds backward / forward functionality to elements.
-import { registerMethods } from './methods.js'
-
-// Get all siblings, including myself
-export function siblings () {
- return this.parent().children()
-}
-
-// Get the curent position siblings
-export function position () {
- return this.parent().index(this)
-}
-
-// Get the next element (will return null if there is none)
-export function next () {
- return this.siblings()[this.position() + 1]
-}
-
-// Get the next element (will return null if there is none)
-export function prev () {
- return this.siblings()[this.position() - 1]
-}
-
-// Send given element one step forward
-export function forward () {
- var i = this.position() + 1
- 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 (typeof p.isRoot === 'function' && p.isRoot()) {
- p.node.appendChild(p.defs().node)
- }
-
- return this
-}
-
-// Send given element one step backward
-export function backward () {
- var i = this.position()
-
- if (i > 0) {
- this.parent().removeElement(this).add(this, i - 1)
- }
-
- return this
-}
-
-// Send given element all the way to the front
-export function front () {
- var p = this.parent()
-
- // Move node forward
- p.node.appendChild(this.node)
-
- // Make sure defs node is always at the top
- if (typeof p.isRoot === 'function' && p.isRoot()) {
- p.node.appendChild(p.defs().node)
- }
-
- return this
-}
-
-// Send given element all the way to the back
-export function back () {
- if (this.position() > 0) {
- this.parent().removeElement(this).add(this, 0)
- }
-
- return this
-}
-
-// Inserts a given element before the targeted element
-export function before (element) {
- element.remove()
-
- var i = this.position()
-
- this.parent().add(element, i)
-
- return this
-}
-
-// Inserts a given element after the targeted element
-export function after (element) {
- element.remove()
-
- var i = this.position()
-
- this.parent().add(element, i + 1)
-
- return this
-}
-
-registerMethods('Dom', {
- siblings, position, next, prev, forward, backward, front, back, before, after
-})