fuse 1.8.1 - Mac Os Sierra
Hello! I have a ScrollView which I populate with Each. I need that from every item I can scroll to the next item through a special button
I tried to use bringToview but it seems that it does not work correctly when the item name target is dynamically generated. Instead if it is static it works correctly. It seems to be a bug. do you have any alternatives to suggest? I also tried with scrollTo and Y (targetNode) but it did not work anyway.
VIDEO ISSUE:
Here the complete reproduction:
<App>
<JavaScript>
var Observable = require("FuseJS/Observable");
var nodeFocus = Observable();
var items = Observable();
var data =[{
id:"item1",
next:"item2"
},
{
id:"item2",
next:"item3"
},
{
id:"item3",
next:"item4"
}
,
{
id:"item4",
next:"item5"
}
,
{
id:"item5",
next:"item6"
}];
items.replaceAll(data);
function OnNext(args){
nodeFocus.value=args.data.next;
setTimeout(function () {
nodeFocus.value = null;
}, 500);
}
function OnLastItem(args){
nodeFocus.value="LastItem";
setTimeout(function () {
nodeFocus.value = null;
}, 500);
}
module.exports={
items:items,
OnNext:OnNext,
OnLastItem:OnLastItem,
nodeFocus:nodeFocus
}
</JavaScript>
<ScrollView Margin="10" ux:Name="scroller">
<StackPanel ItemSpacing="500">
<Each Items="{items}">
<DockPanel ux:Name="{id}">
<Text>{id}</Text>
<Button Dock="Right" Text="Next Item" Clicked="{OnNext}"/>
<Text Dock="Right"> | </Text>
<Button Dock="Right" Text="Last Item" Clicked="{OnLastItem}"/>
</DockPanel>
</Each>
<DockPanel ux:Name="LastItem">
<Text>LAST ITEM</Text>
</DockPanel>
</StackPanel>
<WhileString Value="{nodeFocus}" Test="IsNotEmpty">
<BringIntoView TargetNode="{nodeFocus}"/>
<!-- alternative to BringIntoView but it not works same
<ScrollTo Target="scroller" Position="0,{=y({nodeFocus})}" />
-->
</WhileString>
</ScrollView>
</App>