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

Prevent TopAppbar from partially visible #34

Closed
Rahulkr2 opened this issue Mar 5, 2022 · 2 comments
Closed

Prevent TopAppbar from partially visible #34

Rahulkr2 opened this issue Mar 5, 2022 · 2 comments
Labels
feature New feature or request support Asking for help regarding to the usage of library

Comments

@Rahulkr2
Copy link

Rahulkr2 commented Mar 5, 2022

If scroll is more than 50% than for positive scroll show toolbar and negative scroll hide toolbar.
I don't want toolbar to be partially visible.
Please tell me how to achieve this behavior.

@onebone onebone added feature New feature or request support Asking for help regarding to the usage of library labels Mar 7, 2022
@onebone
Copy link
Owner

onebone commented Mar 7, 2022

There is no official way to implement this, but is being implemented with #14.

For now, you can implement it by intercepting nestedScroll by yourself.

CollapsingToolbarScaffold(
	modifier = Modifier.fillMaxSize()
		.nestedScroll(object : NestedScrollConnection {
			override suspend fun onPostFling(
				consumed: Velocity,
				available: Velocity
			): Velocity {
				@OptIn(ExperimentalToolbarApi::class)
				if (state.toolbarState.progress < 0.5) {
					state.toolbarState.collapse()
				} else {
					state.toolbarState.expand()
				}

				return Velocity.Zero
			}
		}),
	// ...
)

@onebone onebone closed this as completed Mar 7, 2022
@SECURISTAX
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request support Asking for help regarding to the usage of library
Projects
None yet
Development

No branches or pull requests

3 participants