diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-27 23:04:21 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-27 23:04:21 +0200 |
commit | 6a85fb99391e73ee551e4913f9199d426ddf93c7 (patch) | |
tree | e40b4996ca54ecf57f913c54a60f3efb361b8623 | |
parent | cbf1359e0ab469e1137450192b7d612501c4bb5c (diff) | |
download | svg.js-6a85fb99391e73ee551e4913f9199d426ddf93c7.tar.gz svg.js-6a85fb99391e73ee551e4913f9199d426ddf93c7.zip |
satisfy linter
-rw-r--r-- | src/animator.js | 6 | ||||
-rw-r--r-- | src/color.js | 2 | ||||
-rw-r--r-- | src/default.js | 2 | ||||
-rw-r--r-- | src/elemnts-svg.js | 34 | ||||
-rw-r--r-- | src/helpers.js | 3 | ||||
-rw-r--r-- | src/matrix.js | 23 | ||||
-rw-r--r-- | src/point.js | 1 | ||||
-rw-r--r-- | src/queue.js | 13 | ||||
-rw-r--r-- | src/transform.js | 2 |
9 files changed, 51 insertions, 35 deletions
diff --git a/src/animator.js b/src/animator.js index ea3b605..4505eec 100644 --- a/src/animator.js +++ b/src/animator.js @@ -54,14 +54,12 @@ SVG.Animator = { }, _draw: function (now) { - // Run all the timeouts we can run, if they are not ready yet, add them // to the end of the queue immediately! (bad timeouts!!! [sarcasm]) - var tracking = true + // var tracking = true // FIXME: Not used var nextTimeout = null
var lastTimeout = SVG.Animator.timeouts.last() while ((nextTimeout = SVG.Animator.timeouts.shift())) { - // Run the timeout if its time, or push it to the end if (now >= nextTimeout.time) { nextTimeout.run() @@ -74,7 +72,7 @@ SVG.Animator = { } // Run all of the frames available up until this point - var lastFrame = SVG.Animator.frames.last() + // var lastFrame = SVG.Animator.frames.last() // FIXME: Not used var lastFrameId = SVG.Animator.frameCount while (SVG.Animator.frames.first() && SVG.Animator.frames.first().id < lastFrameId) { var nextFrame = SVG.Animator.frames.shift() diff --git a/src/color.js b/src/color.js index cb1500a..43bafcb 100644 --- a/src/color.js +++ b/src/color.js @@ -67,7 +67,7 @@ SVG.Color = function (color, g, b) { this.r = color.r this.g = color.g this.b = color.b - } else if(arguments.length == 3) { + } else if (arguments.length === 3) { this.r = color this.g = g this.b = b diff --git a/src/default.js b/src/default.js index 0a74f13..e82d1db 100644 --- a/src/default.js +++ b/src/default.js @@ -7,7 +7,7 @@ SVG.defaults = { timeline: { duration: 400, ease: '>', - delay: 0, + delay: 0 }, // Default attribute values diff --git a/src/elemnts-svg.js b/src/elemnts-svg.js new file mode 100644 index 0000000..082ccd5 --- /dev/null +++ b/src/elemnts-svg.js @@ -0,0 +1,34 @@ + // Import raw svg + svg: function (svg) { + var well, len + + // act as getter if no svg string is given + if(svg == null || svg === true) { + // write svgjs data to the dom + this.writeDataToDom() + + // return outer or inner content + return svg + ? this.node.innerHTML + : this.node.outerHTML + } + + // act as setter if we got a string + + // make sure we are on a parent when trying to import + if(!(this instanceof SVG.Parent)) + throw Error('Cannot import svg into non-parent element') + + // create temporary holder + well = document.createElementNS(SVG.ns, 'svg') + + // dump raw svg + well.innerHTML = svg + + // transplant nodes + for (len = well.children.length; len--;) { + this.node.appendChild(well.firstElementChild) + } + + return this + },
\ No newline at end of file diff --git a/src/helpers.js b/src/helpers.js index 84b78ad..fca14df 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -206,7 +206,6 @@ function closeEnough (a, b, threshold) { // TODO: Refactor this to a static function of matrix.js function formatTransforms (o) { - // Get all of the parameters required to form the matrix var flipBoth = o.flip === 'both' || o.flip === true var flipX = o.flip && (flipBoth || o.flip === 'x') ? -1 : 1 @@ -257,6 +256,6 @@ function formatTransforms (o) { ox: ox, oy: oy, px: px, - py: py, + py: py } } diff --git a/src/matrix.js b/src/matrix.js index 3636124..4ddb43d 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -1,27 +1,17 @@ /* global abcdef, arrayToMatrix, closeEnough, formatTransforms */ -function translate () { - -} - -function functionName() { - -} - - SVG.Matrix = SVG.invent({ // Initialize create: function (source) { var base = arrayToMatrix([1, 0, 0, 1, 0, 0]) - var i // ensure source as object source = source instanceof SVG.Element ? source.matrixify() : typeof source === 'string' ? arrayToMatrix(source.split(SVG.regex.delimiter).map(parseFloat)) : Array.isArray(source) ? arrayToMatrix(source) : (typeof source === 'object' && ( - source.a != null || source.b != null || source.c != null - || source.d != null || source.e != null || source.f != null + source.a != null || source.b != null || source.c != null || + source.d != null || source.e != null || source.f != null )) ? source : (typeof source === 'object') ? new SVG.Matrix().transform(source) : arguments.length === 6 ? arrayToMatrix([].slice.call(arguments)) @@ -46,7 +36,6 @@ SVG.Matrix = SVG.invent({ // Transform a matrix into another matrix by manipulating the space transform: function (o) { - // Check if o is a matrix and then left multiply it directly if (o.a != null) { var matrix = new SVG.Matrix(o) @@ -71,7 +60,6 @@ SVG.Matrix = SVG.invent({ // If we want the origin at a particular place, we force it there if (isFinite(t.px) || isFinite(t.py)) { - // Figure out where the origin went and the delta to get there var current = new SVG.Point(t.ox - t.rx, t.oy - t.ry).transform(transformer) var dx = t.px ? t.px - current.x : 0 @@ -201,7 +189,6 @@ SVG.Matrix = SVG.invent({ // Inverses matrix inverse: function () { - // Get the current parameters out of the matrix var a = this.a var b = this.b @@ -212,7 +199,7 @@ SVG.Matrix = SVG.invent({ // Invert the 2x2 matrix in the top left var det = a * d - b * c - if (!det) throw new Error("Cannot invert " + this) + if (!det) throw new Error('Cannot invert ' + this) // Calculate the top 2x2 matrix var na = d / det @@ -221,8 +208,8 @@ SVG.Matrix = SVG.invent({ var nd = a / det // Apply the inverted matrix to the top right - var ne = - ( na * e + nc * f ) - var nf = - ( nb * e + nd * f ) + var ne = -(na * e + nc * f) + var nf = -(nb * e + nd * f) // Construct the inverted matrix return new SVG.Matrix(na, nb, nc, nd, ne, nf) diff --git a/src/point.js b/src/point.js index 9fd3c5a..6c64ed6 100644 --- a/src/point.js +++ b/src/point.js @@ -55,7 +55,6 @@ SVG.Point = SVG.invent({ // transform point with matrix transform: function (m) { - // Perform the matrix multiplication var x = m.a * this.x + m.c * this.y + m.e var y = m.b * this.x + m.d * this.y + m.f diff --git a/src/queue.js b/src/queue.js index abcfb84..290de26 100644 --- a/src/queue.js +++ b/src/queue.js @@ -8,7 +8,6 @@ SVG.Queue = SVG.invent({ extend: { push: function (value) { - // An item stores an id and the provided value var item = { id: this.id++, value: value } @@ -23,8 +22,8 @@ SVG.Queue = SVG.invent({ }, shift: function () { - if (this.length == 0) { - return + if (!this.length) { + return null } var remove = this._first @@ -48,8 +47,8 @@ SVG.Queue = SVG.invent({ // Find the first match var previous = null var current = this._first - while (current) { + while (current) { // If we have a match, we are done if (matcher(current)) break @@ -59,12 +58,14 @@ SVG.Queue = SVG.invent({ } // If we got the first item, adjust the first pointer - if (current && current === this._first) + if (current && current === this._first) { this._first = this._first.next + } // If we got the last item, adjust the last pointer - if (current && current === this._last) + if (current && current === this._last) { this._last = previous + } // If we got an item, fix the list and return the item if (current) { diff --git a/src/transform.js b/src/transform.js index 758f40a..2a829bd 100644 --- a/src/transform.js +++ b/src/transform.js @@ -51,7 +51,6 @@ SVG.extend(SVG.Element, { // Add transformations transform: function (o, relative) { - // Act as a getter if no object was passed if (o == null || typeof o === 'string') { var decomposed = new SVG.Matrix(this).decompose() @@ -61,7 +60,6 @@ SVG.extend(SVG.Element, { } else if (typeof o.origin === 'string' || (o.origin == null && o.ox == null && o.oy == null) ) { - // Get the bounding box of the element with no transformations applied var bbox = this.bbox() |