I’m wondering if this is what I’m looking for to control my navigation…
Match case is mostly used for placing different types of elements based on some value
For example:
<JavaScript>
var Observable = require("FuseJS/Observable");
var someValue = Observable("someString");
module.exports = { someValue : someValue };
</JavaScript>
<Panel>
<Match Value="{someString}">
<Case String="someValue">
<Text TextColor="#fff" Value="String is some value"/>
</Case>
<Case String="someOtherValue">
<Text TextColor="#f00" Value="String is some other value"/>
</Case>
<Case Bool="true">
<!--if the value is of type bool and is true, this case is used-->
</Case>
</Match>
</Panel>
For controlling navigation, you would usually change the Active property on your Navigation
, either by databinding to JS or using a Change
or Set
animator.
Could you ellaborate some more on what you are trying to do?
Thank you! That’s all I needed…
The purpose is to get rid of nonsense code like this in my .js:
menuDiscNav: activeView.map(function(op) {
if (op=="content") return "hamburger";
if (op=="sidebar") return "close";
return "back";
}),
showMainView: activeView.map(function(op) {
var ret = op=="content" || op=="sidebar";
return ret;
}),
showSidebar: activeView.map(function(op) {
var ret = op=="sidebar";
return ret;
}),
showTrioMessage: activeView.map(function(op) {
var ret = op=="error" || op=="trio";
return ret;
}),
trioErrorActive: activeView.map(function(op) {
var ret = op=="error";
return ret;
})
More concretely: I have a variable called “mainView” that can be one of “trio”, “error”, “sidebar” and “content”. The user interface animates in fancy ways to switch between the four modes, so there’s a few different things that need to be controlled. Hence the above javascript-mess before you showed me how to use Match
Yeah, this is exactly what Match/Case is for. I love that feature, glad it was useful to you as well