Famous / Famous/engine

DOMElement.onShow should not update display property to block when its node.isShown() is false

Open
#470 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.7k
Forks
249
PR merge metrics
No merged PRs in 30d

Description

Here's an example to test.
1. Add parent node and two child nodes(child1, child2)
2. Run child1.hide()
3. Run parent node.hide()
4. Run parent node.show()

In this case, child1(red) should not be displayed, but it does.

There might be two possible ways to fix this,
1. Modify DOMElement.onShow not to change property when its Node.isShown() is false
2. Modify Dispatch.show to ignore nodes which Node.isShown() is false

I think although Node.isShown() is false, Node would be better to get onShow events from Dispatch.
So I chose the first one to fix this.
How do you think?

``` javascript
'use strict';

// Famous dependencies
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');

FamousEngine.init();
var node = FamousEngine.createScene().addChild();
var child1 = node.addChild();
var child2 = node.addChild();

child1.el = new DOMElement(child1, {
tagName: 'div',
properties: {
'background-color': 'red'
}
});

child2.el = new DOMElement(child2, {
tagName: 'div',
properties: {
'background-color': 'blue'
}
});

child1
.setSizeMode('absolute', 'absolute')
.setAbsoluteSize(100, 100)
.setAlign(0.5, 0.5)
.setMountPoint(0.5, 0.5)
.setPosition(-50, 0);

child2
.setSizeMode('absolute', 'absolute')
.setAbsoluteSize(100, 100)
.setAlign(0.5, 0.5)
.setMountPoint(0.5, 0.5)
.setPosition(50, 0);

child1.hide();
node.hide();
node.show();
/*
* child1(red) should not be shown
*/
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.