summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-19 20:45:07 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-19 20:45:07 +0100
commit9943813f3779d2ede508a90dadd087fc0ad12f1f (patch)
tree9e0d2c1008ed540936ca9675152f6ba79ff4bd64 /src
parentd5a8faa4d06d2664a7748ea570937751ef5271d5 (diff)
downloadsvg.js-9943813f3779d2ede508a90dadd087fc0ad12f1f.tar.gz
svg.js-9943813f3779d2ede508a90dadd087fc0ad12f1f.zip
renamed `Doc` to `Svg` according to (#932)
Diffstat (limited to 'src')
-rw-r--r--src/animation/Timeline.js19
-rw-r--r--src/elements/Container.js2
-rw-r--r--src/elements/Element.js4
-rw-r--r--src/elements/Svg.js (renamed from src/elements/Doc.js)6
-rw-r--r--src/main.js6
5 files changed, 17 insertions, 20 deletions
diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js
index f1d540a..6abcb80 100644
--- a/src/animation/Timeline.js
+++ b/src/animation/Timeline.js
@@ -1,8 +1,7 @@
+import { globals } from '../utils/window.js'
import { registerMethods } from '../utils/methods.js'
import Animator from './Animator.js'
-import { globals } from '../utils/window.js'
-
-var time = globals.window.performance || Date
+import EventTarget from '../types/EventTarget.js'
var makeSchedule = function (runnerInfo) {
var start = runnerInfo.start
@@ -11,15 +10,16 @@ var makeSchedule = function (runnerInfo) {
return { start: start, duration: duration, end: end, runner: runnerInfo.runner }
}
-export default class Timeline {
+export default class Timeline extends EventTarget {
// Construct a new timeline on the given element
constructor () {
+ super()
+
this._timeSource = function () {
- return time.now()
+ let w = globals.window
+ return (w.performance || w.Date).now()
}
- this._dispatcher = globals.document.createElement('div')
-
// Store the timing variables
this._startTime = 0
this._speed = 1.0
@@ -38,16 +38,13 @@ export default class Timeline {
this._lastStepTime = 0
}
- getEventTarget () {
- return this._dispatcher
- }
-
/**
*
*/
// schedules a runner on the timeline
schedule (runner, delay, when) {
+ // FIXME: how to sort? maybe by runner id?
if (runner == null) {
return this._runners.map(makeSchedule).sort(function (a, b) {
return (a.start - b.start) || (a.duration - b.duration)
diff --git a/src/elements/Container.js b/src/elements/Container.js
index 9415341..b47972e 100644
--- a/src/elements/Container.js
+++ b/src/elements/Container.js
@@ -8,7 +8,7 @@ export default class Container extends Element {
return this.toParent(parent)
})
- // we need this so that Doc does not get removed
+ // we need this so that the root does not get removed
this.node.firstElementChild || this.remove()
return this
diff --git a/src/elements/Element.js b/src/elements/Element.js
index 456ddad..1f208c5 100644
--- a/src/elements/Element.js
+++ b/src/elements/Element.js
@@ -15,7 +15,7 @@ import Dom from './Dom.js'
import List from '../types/List.js'
import SVGNumber from '../types/SVGNumber.js'
-const Doc = getClass(root)
+const Svg = getClass(root)
export default class Element extends Dom {
constructor (node, attrs) {
@@ -57,7 +57,7 @@ export default class Element extends Dom {
// Get parent document
doc () {
- let p = this.parent(Doc)
+ let p = this.parent(Svg)
return p && p.doc()
}
diff --git a/src/elements/Doc.js b/src/elements/Svg.js
index d56fae3..e634c6a 100644
--- a/src/elements/Doc.js
+++ b/src/elements/Svg.js
@@ -10,7 +10,7 @@ import Container from './Container.js'
import Defs from './Defs.js'
import { globals } from '../utils/window.js'
-export default class Doc extends Container {
+export default class Svg extends Container {
constructor (node) {
super(nodeOrNew('svg', node), node)
this.namespace()
@@ -70,9 +70,9 @@ registerMethods({
Container: {
// Create nested svg document
nested: wrapWithAttrCheck(function () {
- return this.put(new Doc())
+ return this.put(new Svg())
})
}
})
-register(Doc, 'Doc', true)
+register(Svg, 'Svg', true)
diff --git a/src/main.js b/src/main.js
index 701b23b..919fb25 100644
--- a/src/main.js
+++ b/src/main.js
@@ -14,7 +14,6 @@ import Circle from './elements/Circle.js'
import Color from './types/Color.js'
import Container from './elements/Container.js'
import Defs from './elements/Defs.js'
-import Doc from './elements/Doc.js'
import Dom from './elements/Dom.js'
import Element from './elements/Element.js'
import Ellipse from './elements/Ellipse.js'
@@ -43,6 +42,7 @@ import Runner from './animation/Runner.js'
import SVGArray from './types/SVGArray.js'
import SVGNumber from './types/SVGNumber.js'
import Shape from './elements/Shape.js'
+import Svg from './elements/Svg.js'
import Text from './elements/Text.js'
import Tspan from './elements/Tspan.js'
import * as defaults from './modules/core/defaults.js'
@@ -90,7 +90,6 @@ export { default as Circle } from './elements/Circle.js'
export { default as ClipPath } from './elements/ClipPath.js'
export { default as Container } from './elements/Container.js'
export { default as Defs } from './elements/Defs.js'
-export { default as Doc } from './elements/Doc.js'
export { default as Dom } from './elements/Dom.js'
export { default as Element } from './elements/Element.js'
export { default as Ellipse } from './elements/Ellipse.js'
@@ -110,6 +109,7 @@ export { default as Rect } from './elements/Rect.js'
export { default as Shape } from './elements/Shape.js'
export { default as Stop } from './elements/Stop.js'
export { default as Style } from './elements/Style.js'
+export { default as Svg } from './elements/Svg.js'
export { default as Symbol } from './elements/Symbol.js'
export { default as Text } from './elements/Text.js'
export { default as TextPath } from './elements/TextPath.js'
@@ -117,7 +117,7 @@ export { default as Tspan } from './elements/Tspan.js'
export { default as Use } from './elements/Use.js'
extend([
- Doc,
+ Svg,
Symbol,
Image,
Pattern,