pageLayout.pullToCollapseListener.apply {
// Threshold distance for collapsing the page when
// its pulled (upwards/downwards). Defaults to 56dp.
collapseDistanceThreshold = THRESHOLD_IN_PIXELS
// The page isn't moved with the same speed as the finger. Some friction
// is applied to make the gesture feel nice. This friction is increased
// further once the page is eligible for collapse as a visual indicator
// that the page should no longer be dragged. Setting this to 1f will
// remove the friction entirely. Defaults to 3.5f.
pullFrictionFactor = 3.5f
}
ExpandablePageLayout
currently does not understand nested scrolling, so if the content contains scrollable child Views, the pull-to-collapse gesture will have to be intercepted manually.
expandablePage.pullToCollapseInterceptor = { downX, downY, upwardPull ->
val directionInt = if (upwardPull) +1 else -1
val canScrollFurther = scrollableContainer.canScrollVertically(directionInt)
if (canScrollFurther) InterceptResult.INTERCEPTED else InterceptResult.IGNORED
}
When the scrollable children do not consume the entire space, the downX
and downY
parameters can be used to check if the touch actually lies on them. See the sample app for an example.