scope: tweakedy tweakeda fonk
This commit is contained in:
parent
83090d2e06
commit
d69d3b7f13
4 changed files with 26 additions and 16 deletions
|
|
@ -271,13 +271,16 @@ class WidgetManager extends EventEmitter {
|
|||
/*
|
||||
scopable: return matching widgets only for the closest scope with results
|
||||
*/
|
||||
if (scope) {
|
||||
if (scope && scope.length) {
|
||||
if (!Array.isArray(scope)) scope = [scope]
|
||||
for (var prefix of scope) {
|
||||
var prefixedId = Array.isArray(id) ? id.map(i=>prefix + i) : prefix + id
|
||||
|
||||
var widgets = this.getWidgetBy(prefixedId, this.idRoute)
|
||||
|
||||
if (widgets.length) return widgets
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
return this.getWidgetBy(id, this.idRoute)
|
||||
|
|
|
|||
|
|
@ -431,9 +431,11 @@ class Widget extends EventEmitter {
|
|||
parent = parent.parent
|
||||
} while (parent.meta.scopable || parent.getProp('scopedId'))
|
||||
for (var i=0; i < this.scopes.length; i++) {
|
||||
this.scopes[i] = this.scopes.slice(i).reverse().join('/')
|
||||
this.scopes[i] = this.scopes.slice(i).reverse().join('/') + '/'
|
||||
}
|
||||
}
|
||||
// include global scope
|
||||
if (this.scopes.length) this.scopes.push('')
|
||||
|
||||
// @{props} links lists
|
||||
this.linkedProps = {}
|
||||
|
|
@ -549,11 +551,11 @@ class Widget extends EventEmitter {
|
|||
/*
|
||||
scopable: attempt to resolve scoped widget updates against ids in advanced syntax blocks
|
||||
*/
|
||||
if (this.meta.scopable) {
|
||||
if (this.scopes.length) {
|
||||
var unprefixedId
|
||||
for (var p of this.scopes) {
|
||||
if (id.includes(p)) {
|
||||
unprefixedId = id.replace(p + '/', '')
|
||||
unprefixedId = id.replace(p, '')
|
||||
if (this.nestedLinkedProps[unprefixedId] || linkedProps[unprefixedId]) {
|
||||
id = unprefixedId
|
||||
break
|
||||
|
|
@ -957,7 +959,7 @@ class Widget extends EventEmitter {
|
|||
*/
|
||||
case 'id':
|
||||
if (this.scopes.length) {
|
||||
propValue = this.scopes[0] + '/' + propValue
|
||||
propValue = this.scopes[0] + propValue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,10 @@ class Clone extends Container() {
|
|||
.filter(w=>this.isValidCloneTarget(w))
|
||||
target = widgets[0]
|
||||
|
||||
if (!target) continue
|
||||
if (!target) {
|
||||
rank++
|
||||
continue
|
||||
}
|
||||
|
||||
for (var w of widgets) {
|
||||
// when duplicating clones pointing to an object with a static id,
|
||||
|
|
@ -135,7 +138,7 @@ class Clone extends Container() {
|
|||
}
|
||||
}
|
||||
|
||||
if (target && (rank < this.targetRank || this.targetRank == null)) {
|
||||
if (rank < this.targetRank || this.targetRank == null) {
|
||||
|
||||
var clone = this.children[0]
|
||||
|
||||
|
|
@ -153,11 +156,9 @@ class Clone extends Container() {
|
|||
this.updateClone()
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
rank++
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
this.rangeVals[1] = 0
|
||||
}
|
||||
|
||||
this.getScrollTarget()
|
||||
|
||||
widgetManager.on('widget-created', (e)=>{
|
||||
|
||||
|
|
@ -59,13 +58,15 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
if (!this.scopes.length && this.scrollTarget) return
|
||||
|
||||
var {id, widget} = e
|
||||
|
||||
if (id.includes(this.getProp('widgetId')) && widget.getProp('scroll')) {
|
||||
|
||||
this.getScrollTarget()
|
||||
}
|
||||
|
||||
}, {context: this})
|
||||
|
||||
this.getScrollTarget()
|
||||
|
||||
}
|
||||
|
||||
getScrollTarget() {
|
||||
|
|
@ -79,16 +80,19 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
.filter(w=>w.getProp('scroll'))
|
||||
target = widgets[0]
|
||||
|
||||
if (!target) continue
|
||||
if (!target) {
|
||||
rank++
|
||||
continue
|
||||
}
|
||||
|
||||
if (target && (rank < this.targetRank || this.targetRank == null)) {
|
||||
if (rank < this.targetRank || this.targetRank == null) {
|
||||
if (this.scopes.length) this.log(rank)
|
||||
|
||||
this.unbindTarget()
|
||||
this.bindTarget(target, rank)
|
||||
return
|
||||
}
|
||||
|
||||
rank++
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue