widgets: prevent non-dynamic properties updates from breaking an osc sending event chain (#342)
This commit is contained in:
parent
fc1c72fb58
commit
556892f941
4 changed files with 12 additions and 9 deletions
|
|
@ -36,7 +36,7 @@ var updateWidget = function(widget, options = {}) {
|
|||
widgetManager.removeWidgets(oldWidgets)
|
||||
|
||||
// widget
|
||||
var newWidget = parser.parse([widget.props], widget.parentNode, widget.parent)
|
||||
var newWidget = parser.parse([widget.props], widget.parentNode, widget.parent, false, options.reCreateOptions)
|
||||
|
||||
widget.container.parentNode.replaceChild(newWidget.container, widget.container)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ var Parser = class Parser {
|
|||
|
||||
}
|
||||
|
||||
parse(data, parentNode, parentWidget, tab) {
|
||||
parse(data, parentNode, parentWidget, tab, reCreateOptions) {
|
||||
|
||||
for (let i in data) {
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ var Parser = class Parser {
|
|||
|
||||
|
||||
// create widget
|
||||
var widget = new this.widgets[props.type]({props:props, container:true, parent:parentWidget, parentNode:parentNode})
|
||||
var widget = new this.widgets[props.type]({props:props, container:true, parent:parentWidget, parentNode:parentNode, reCreateOptions})
|
||||
|
||||
widgetManager.addWidget(widget)
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class Widget extends EventEmitter {
|
|||
this.parentNode = options.parentNode
|
||||
this.hash = shortid.generate()
|
||||
this.childrenHashes = []
|
||||
this.reCreateOptions = options.reCreateOptions
|
||||
|
||||
// strip parent ? no position
|
||||
if (this.parent && this.parent.props && this.parent.props.type == 'strip') {
|
||||
|
|
@ -82,11 +83,11 @@ class Widget extends EventEmitter {
|
|||
if (Object.keys(this.linkedProps).length) {
|
||||
|
||||
widgetManager.on(`widget-created.${this.hash}`, (e)=>{
|
||||
var {id, widget} = e
|
||||
var {id, widget, options} = e
|
||||
if (widget == this.parent) return
|
||||
if (widget == this) id = 'this'
|
||||
if (this.linkedProps[id]) {
|
||||
this.updateProps(this.linkedProps[id], widget)
|
||||
this.updateProps(this.linkedProps[id], widget, options)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -166,7 +167,8 @@ class Widget extends EventEmitter {
|
|||
|
||||
this.trigger('widget-created.*', [{
|
||||
id: this.getProp('id'),
|
||||
widget: this
|
||||
widget: this,
|
||||
options: this.reCreateOptions
|
||||
}])
|
||||
|
||||
}
|
||||
|
|
@ -453,7 +455,7 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
if (reCreate && this.childrenHashes.indexOf(widget.hash) == -1 && !(widget === this && updatedProps.length === 1 && updatedProps[0] === 'value')) {
|
||||
|
||||
this.reCreateWidget()
|
||||
this.reCreateWidget(options)
|
||||
return true
|
||||
|
||||
} else if (changedProps.length) {
|
||||
|
|
@ -614,9 +616,9 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
reCreateWidget(){
|
||||
reCreateWidget(options){
|
||||
|
||||
updateWidget(this, {remote: true})
|
||||
updateWidget(this, {remote: true, reCreateOptions:options})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue