NativeScript ListView scroll event - ios

How can I detect when a ListView is scrolled?
I tried wrapping the ListView in a ScrollView and using the scroll event on the ScrollView. Doesn't work.

I've used the PanGesture on a ListView to capture when a user is scrolling up or down.
const panEvent$ = fromEvent(this.listView, 'pan').pipe(map(
(event: PanGestureEventData) => event.deltaY
));
This will take my listView property and only emit the Y values. you can then determine if they are moving up or down if Y is greater than 0

Related

How to scroll to a certain item in a Column(Modifier.verticalScroll())?

I have a Column with TextViews with indices from -10 to 10.
Column(
modifier = modifier
.verticalScroll(
state = scrollState,
enabled = isScrollEnabled,
reverseScrolling = reverseScrollDirection
)) {
for(i in -10..10) {
TextView("Index $i")
}
}
Naturally, this Column start with -10 and is incrementing by 1 until 10; so I have to scroll forward all the 21 indices (picture left hand side).
How can I align 0 to the beginning, so that I start the view scrollable either 10 back until -10 or 10 forward until 10 (see attached picture right hand side)?
Column doesn't have a concept of item, it has just a bunch of composable functions called inside of it. Because of that, ScrollState only has a method to scroll to position in pixels.
If you know the height of your items, you can calculate the pixel position and pass it to rememberScrollState(). Otherwise, you can use LazyColumn which can scroll to specific item.

Flutter ScrollController finout max offset

I would like to make some kind of custom scroll progress indicator for CustomScrollView.
_scrollController = ScrollController()..addListener(_scroll);
void _scroll() {
print('scrolled ${_scrollController.offset} from {??}');
}
Is there way to findout _scrollController max offset?
Or could I get some value form Scrollbar widget?
So all you need is
scrollController.position.maxScrollExtent
This gives you the max scroll extent for the ListView

Adding a scrollbar to ui-grid overlays the bottom row

An application that I'm working on has a ui-grid on the page. Recently, we added a horizontal scrollbar to the grid and also enabled "pinning" so that some of the columns could be frozen while the grid was scrolled horizontally.
One odd behavior that I've noticed is that the newly added scrollbar overlays the last row in the table. Has anyone else ever experienced this and, if so, figured out how to stop it from happening? I've tried everything I could think of (i.e. changing row height, dynamic sizing of the grid, etc) but nothing is working. I'm hoping someone else has overcome this issue and can tell me how they did it.
Well, I found a way to resolve this, but it's particular to how our grids are created.
All of our grids that have horizontal scrolling have the first three columns pinned. I used the code below to see if the grid in question has the grid option for pinning. If the grid is scrollable, I simply add 15 to the grid's height. This makes the grid bigger so that there's plenty of room for the scrollbar without it overlaying the bottom row.
var scrollbarOffset = 15;
var buffer = 5;
var gridHeight = ((rowCount > 0 ? rowCount : 1) * rowHeight) + footer + header + filter + buffer;
var scrollable= $.grep(element[0].attributes,
function (rn) {
return rn.nodeName === "ui-grid-pinning";
}).length > 0;
if (scrollable) {
gridHeight = gridHeight + scrollbarOffset;
}

How to add touch and scroll event on a button on a top of scroll view Corona?

I'm creating level selection scene in corona. To accomplish this I have used scrollview and I have added a group of buttons to this scrollview.
But my problem is that I can scroll when I touch the background of the scrollview but I when I touch any of this button the scroll view didn't scroll.
What I need is to handle to events onpress on the button and scroll for the scroll view
so any ideas to how I can scroll the scroll view if I touch and hold on the button then I scrolled my finger?
I have solved my problem using takefocus method inside the button listener with this code
if ( phase == "moved" ) then
local dy = math.abs( ( event.y - event.yStart ) )
-- If the touch on the button has moved more than 10 pixels,
-- pass focus back to the scroll view so it can continue scrolling
if ( dy > 10 ) then
scrollView:takeFocus( event )
end
end

TextField Not horizontal scrolling with text[Titanium]

I want the textarea to scroll horizontally once the test string has exceeded the width of the textarea. I tried the below code, but however, it does not work for some reason.
I also tried adding a wrapper view to scroll view and adding the textarea to the wrapper view; but that does not work either.
How can I fix this ?
var scroll = Ti.UI.createScrollView({
top:40,
left:230,
width:290,
height:50
});
win.add(scroll);
var textType = Ti.UI.createTextArea({
backgroundColor:'#E6E6E6',
borderColor:'blue',
borderRadius:10,
top:0,
left:0,
width:290,
height:50,
font:{fontSize:26, fontFamily:customFont},
editable:false,
enabled:false,
textAlign:'right',
scrollable:true
});
scroll.add(textType);
I know that this sound really simple but, for default the text area is vertical scrollable. and this is the only behavior i know of it. i have tried different properties like:
layout:"horizontal",
horizontalWrap:true,
scrollable:true,
But this has not resolve the issue.

Resources