Skip to content

父控件滑动处理 #1

Description

@zengcanxiang
private fun scrollParent(deltaX: Float): Offset {
        val parentIsBetweenPages = parentState.isBetweenPages()
        if (!parentIsBetweenPages && !parentState.canScrollInGestureDirection(deltaX)) {
            parentDragActive = false
            return Offset.Zero
        }

        // PagerState.dispatchRawDelta uses pager scroll coordinates. For LTR horizontal pagers,
        // those coordinates are the opposite of the user's drag delta, so invert both input and
        // return value.
        val consumed = -parentState.dispatchRawDelta(-deltaX)
        if (consumed.absoluteValue > 0f) {
            parentDragActive = true
        }
        return Offset(x = consumed, y = 0f)
    }

中使用-parentState.dispatchRawDelta(-deltaX),会在甩手幅度过大的时候,导致可能滑动很多页

想知道这个思路是为什么?是怕父控件还需要在网上分发吗?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions