-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Use case: simple popup dialog with OK and CANCEL buttons. If the initial state of the popup is visible (for testing), the 'click' events on the buttons work as expected. If the popup node is set hidden via $if and then re-displayed ($if is true), the buttons (child nodes) no longer respond to click events.
FamousFramework.scene('tutaslabs:test', {
behaviors: {
'#popup': {
'align': [0.5, 0.3],
'origin': [0.5, 0.5],
'mount-point': [0.5, 0.5],
'size': [150, 150],
'position-z':1,
'style': {
'background-color': 'red',
'border-radius': '15px',
'padding': '20px'
},
'unselectable': false,
'$if': function(pvisible) {
return pvisible;
}
},
'#button': {
'align': [0.4, 0.4],
'origin': [0.5, 0.5],
'mount-point': [0.5, 0.5],
'size': [100, 30],
'position-z':20,
'style': {
'background-color': 'lightblue',
'border-radius': '15px',
'cursor':'pointer',
'text-align':'center',
'line-height':'30px'
},
'content': 'Ok'
}
},
events: {
'$self': {
'click': function($event,$state) {
alert('background clicked')
$state.set('pvisible',true)
}
},
'#button': {
//this does not work when parent becomes visible from a hidden state ($if was false)
'click': function($event,$state) {
alert('button clicked')
$state.set('pvisible',false)
}
},
'#popup': {
//this works as expected on becoming 'visible' ($if is true)
'click': function($event,$state) {
alert('popup clicked')
$state.set('pvisible',false)
}
}
},
states: {
pvisible: true
},
tree:
`<node id="popup">
<node id="button"></node>
</node>`
});