how to catch an onScroll event in Ti.UI.ListView? - titanium

Is there a way to catch an onScroll event in ListView like it is done for ScrollView?
It is not exposed in SDK, any solution using module or hyperloop is welcome

There is scrollstart and scrollend on a listview, check the docs https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ListView-event-scrollend

Related

How can I detect blur event in React Native tab component?

I'm using rmc-tabs for tab component in React Native.
I'm using video component and want to pause the video when I move to other tab, but I don't know how to do this.
How can I get the blur event in rmc-tabs or are there any other ways to handle blur event in React Native video or view?
if you are using createTabNavigator or createBottomTabNavigator you can use NavigationEvents within the screens inside TabNavigator which allow you to listen to
onWillFocus : before focusing a tab;
onDidFocus : after focusing a tab;
onWillBlur : before losing focus on a tab;
onDidBlur : after losing focus on a tab;

Disable keyboard dismiss from screen when focusout from Textinput - react native

I would like to know if there is a way to show keyboard always if it focuses out from the TextInput in react native.
You can wrap your TextInput by a ScrollView and then use the keyboardShouldPersistTaps='handled' prop in ScrollView to avoid dismissing the keyboard and handle the keyboard dismiss by using Keyboard.dismiss() function in somewhere else.
Read this for more documentation.

Detect when at the top of a ListView

I'm using a ListView component to display a simple list with section headers.
The ListView component has events for onEndReached but I could not find an onBeginningReached event.
How do you detect that a user has scrolled to the very top of the ListView?
There is no such callback provided. Here is a workaround in React Native .. I assume ReactJS should have something similar
<ListView onScroll={this.handleScroll.bind(this)} ... />
handleScroll(event) {
console.log(event.nativeEvent.contentOffset.y);
}
You can see that the value printed when scrolled on top will be negative. See if that works and help..

Setting an initial scroll position of a React Native ListView

I'm trying to set the initial scroll position of a ListView in react native.
Right now, I'm doing this:
componentDidMount() {
let i = this.props.images.indexOf(this.props.current);
if(i != -1) {
this.refs.listView.scrollTo({ x:i*this.props.width, y:0, animated:false });
}
}
where the images prop is the datasource for the ListView, the current prop is where I want to be initially scrolled to, and the width prop is the width of the component. (The component scrolls horizontally).
This works, but there's a delay between the initial render and the call to componentDidMount, giving me a flash of the end of end of the list before the list is scrolled.
Is there a way of setting an initial scroll position of the list? Or better way of doing this to get rid of that flash?
On iOS you can use the ScrollView#contentOffset to set the initial scroll position of a ListView, which inherits the properties of ScrollView.
If you are looking for an Android solution, the ListView.scrollTo method you are calling seems like the best bet for the general case.
That said, if I interpret your code sample correctly, you are using the ListView for a paginated, horizontal list, perhaps with the help of the pagingEnabled property? If this is the case, on Android you might look at using ViewPagerAndroid instead, and setting the initialPage property.

Is there a "rendering complete" event I can use with Dojo Charts?

I would like to show a loading icon while my Dojo Charts are loading and then hide it when the charts are finished rendering. I cannot find documentation that defines what event I can add a dojo.connect to when the chart has finished rendering. For example, I am doing something similar with the ArcGIS mapping API (built on Dojo) where I have a loading icon displayed when the map updates and then I hide it when the map is finished updating using this line of code:
dojo.connect(map, "onUpdateEnd", hideLoading);
I have tried "onUpdateEnd", "onStartup", "postCreate" with no luck. Anyone know if there is a "rendering complete" event I can use with Dojo Charts?
For any one else that requires to listen on a completion of any method of almost any dojo object, look at dojo/aspect.
http://dojotoolkit.org/reference-guide/1.10/dojo/aspect.html
Sample code:
aspect.after(this.chart, "render", function () {
//your code here
console.log("render completed");
});