Added "animate" binding, fixes #70
This commit is contained in:
@@ -50,7 +50,6 @@
|
||||
ronin.controller.add("default","View","Expand Commander",() => { ronin.commander.toggle(true); },"CmdOrCtrl+Shift+K");
|
||||
ronin.controller.add("default","Project","Run",() => { ronin.commander.run(); },"CmdOrCtrl+R");
|
||||
ronin.controller.add("default","Project","Reload Run",() => { ronin.source.revert(); ronin.commander.run(); },"CmdOrCtrl+Shift+R");
|
||||
ronin.controller.add("default","Project", "Animate",() => { ronin.animate(!ronin.always); },"CmdOrCtrl+Shift+T");
|
||||
ronin.controller.add("default","Theme","Open Theme",() => { ronin.theme.open() },"CmdOrCtrl+Shift+O")
|
||||
ronin.controller.add("default","Theme","Reset Theme",() => { ronin.theme.reset() },"CmdOrCtrl+Shift+Backspace")
|
||||
ronin.controller.addSpacer('default', 'Theme', 'Download')
|
||||
|
||||
@@ -31,25 +31,13 @@ function Commander (ronin) {
|
||||
this.hide()
|
||||
}
|
||||
|
||||
this.cache = ''
|
||||
|
||||
this.run = (txt = this._input.value) => {
|
||||
if (txt.indexOf('$') > -1) { ronin.log('Present: $'); return }
|
||||
this.cache = txt
|
||||
if (ronin.always !== true) {
|
||||
ronin.surface.maximize()
|
||||
ronin.interpreter.run(this.cache)
|
||||
}
|
||||
}
|
||||
|
||||
this.loop = () => {
|
||||
ronin.bindings = {}
|
||||
ronin.surface.maximize()
|
||||
ronin.interpreter.run(this.cache)
|
||||
ronin.always === true && requestAnimationFrame(() => this.loop())
|
||||
ronin.interpreter.run(txt)
|
||||
}
|
||||
|
||||
this.load = function (txt) {
|
||||
ronin.animate(false)
|
||||
this._input.value = txt
|
||||
this.run(txt)
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ function Library (ronin) {
|
||||
|
||||
this.map = async (fn, arr) => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const arg = arr[i];
|
||||
const arg = arr[i]
|
||||
await fn(arg)
|
||||
}
|
||||
}
|
||||
@@ -437,10 +437,6 @@ function Library (ronin) {
|
||||
return (Date.now() * rate)
|
||||
}
|
||||
|
||||
this.animate = (play = true) => { // Toggles animation.
|
||||
ronin.animate(play)
|
||||
}
|
||||
|
||||
this.js = () => { // Javascript interop.
|
||||
return window
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@ function Ronin () {
|
||||
this.interpreter = new Lisp(this.library, this.includes)
|
||||
this.osc = new Osc(this)
|
||||
|
||||
// Parameters
|
||||
this.always = false
|
||||
this.bindings = {}
|
||||
|
||||
this.install = function (host = document.body) {
|
||||
@@ -48,6 +46,14 @@ function Ronin () {
|
||||
this.commander.start()
|
||||
this.surface.start()
|
||||
this.osc.start()
|
||||
this.loop()
|
||||
}
|
||||
|
||||
this.loop = () => {
|
||||
if (this.bindings['animate'] && typeof this.bindings['animate'] === 'function') {
|
||||
this.bindings['animate']()
|
||||
}
|
||||
requestAnimationFrame(() => this.loop())
|
||||
}
|
||||
|
||||
this.reset = function () {
|
||||
@@ -62,12 +68,6 @@ function Ronin () {
|
||||
|
||||
}
|
||||
|
||||
this.animate = (b = true) => {
|
||||
if (this.always === b) { return }
|
||||
this.always = b
|
||||
this.commander.loop()
|
||||
}
|
||||
|
||||
this.bind = (event, fn) => {
|
||||
this.bindings[event] = fn
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user