Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): add direction to ListView scrolling #14130

Merged
merged 6 commits into from
Oct 5, 2024

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Oct 3, 2024

iOS currently only adds direction in the scrolling event when you release the finger. This PR adds it to the continuous scrolling (old PR)

var toggle = false;
var sections = [];
const win = Ti.UI.createWindow();
const btn = Ti.UI.createButton({
	title: "change",
	bottom: 20
});
const lbl = Ti.UI.createLabel({
	top: 10,
	right: 10,
	width: Ti.UI.SIZE,
	height: Ti.UI.SIZE
})
const listView = Ti.UI.createListView({
	height: Ti.UI.FILL,
	width: Ti.UI.FILL,
	continuousUpdate: true,
  forceUpdates: false
});

btn.addEventListener("click", function() {
	toggle = !toggle;
	listView.forceUpdates = toggle
	console.log(listView.forceUpdates);
})

for (var s = 0; s < 5; s++) {
	var section = Ti.UI.createListSection({
		headerTitle: 'Section ' + s
	});
	var set = [];
	for (var i = 0; i < 20; ++i) {
		set.push({
			properties: {
				title: 'Item 0 ' + i
			}
		})
	}
	section.setItems(set);
	sections.push(section);
}

listView.sections = sections;
win.add([listView, btn, lbl]);

listView.addEventListener("scrolling", function(e) {
	lbl.text = "Item: " + e.firstVisibleItemIndex + " section:" + e.firstVisibleSectionIndex;
	console.log("Item", e.direction, e.firstVisibleItemIndex, e.firstVisibleSectionIndex, e.top);
})
win.open();
Bildschirmaufnahme.2024-10-03.um.16.04.27.mov

@hansemannn
Copy link
Collaborator

Are there API docs for this already?

@m1ga
Copy link
Contributor Author

m1ga commented Oct 5, 2024

yes, since 5.4.0
https://github.com/tidev/titanium-sdk/blob/master/apidoc/Titanium/UI/ListView.yml#L648-L652
With a note On iOS no event is fired when the finger is not released. With continuousUpdate event you've got it more often but the direction was not yet in there. That was still only fired after touching the screen.

iphone/Classes/TiUIListView.m Outdated Show resolved Hide resolved
Co-authored-by: Hans Knöchel <hansemannn@users.noreply.github.com>
@hansemannn
Copy link
Collaborator

@m1ga The recent changes should fix that - are you okay with these?

@m1ga
Copy link
Contributor Author

m1ga commented Oct 5, 2024

Looking good, code still works fine, thanks 👍

@hansemannn hansemannn merged commit 81d5d1e into master Oct 5, 2024
6 checks passed
@hansemannn hansemannn deleted the iosScrollingDirection branch October 5, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants