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

do you have any examples around combining cursor and touch position? #3

Closed
chrisdrackett opened this issue Feb 18, 2017 · 5 comments
Closed

Comments

@chrisdrackett
Copy link

would be nice to support mobile and desktop in the same component.

@ethanselzer
Copy link
Owner

@chrisdrackett - Thanks very much for your inquiry! I think you raise a great use case! I will create an example of react-cursor-position with react-touch-position and post back here. In the meantime I think a feature detection strategy is one approach that could be taken. It might look something like:

function getIsTouchEnv() {
    return ('ontouchstart' in window);
}

export default () => {
    return getIsTouchEnv()
    ? (
        <ReactTouchPosition {...{
            mapPropNames: ({  touchPosition }) => {  cursorPosition: touchPosition }
        }}>
            <YourComponent />
        </ReactTouchPosition>
    )
    : (
        <ReactCursorPosition>
            <YourComponent />
        </ReactCursorPosition>
    );

@ethanselzer
Copy link
Owner

@chrisdrackett - Your issue has raised my awareness to the value of a solution that unifies touch and pointer environments without a conditional render. I will prioritize creating this and post back here when it is released. In the meantime, if your use case is a better fit for a unified touch and pointer solution, consider something like the example in this gist. I really appreciate you opening this issue. Thanks!

@chrisdrackett
Copy link
Author

no problem, and thanks for this component, it let me simplify our code while adding functionality. Never a bad thing!

@ethanselzer
Copy link
Owner

@chrisdrackett - I'm happy to inform you the latest version of react-cursor-position supports touch screen environments. The release notes contain an overview and cover breaking changes. As always, if you have questions or concerns, please post here or create a new issue.

Thanks again for your input. I think it helped make the project better!

@ethanselzer
Copy link
Owner

Hey @chrisdrackett - I'm closing this due to inactivity. If you have any questions or comments please let me know. Thanks again for opening this issue!

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

No branches or pull requests

2 participants