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

Add more convenient way for vue #2

Open
2 of 3 tasks
CatsJuice opened this issue Jul 5, 2023 · 4 comments
Open
2 of 3 tasks

Add more convenient way for vue #2

CatsJuice opened this issue Jul 5, 2023 · 4 comments
Labels
feature New features Vue Vue framework related

Comments

@CatsJuice
Copy link
Owner

CatsJuice commented Jul 5, 2023

  • Vue composables
  • v-cursor directive
  • Component
    • Maybe IpadCursorProvider, IpadCursor
@CatsJuice CatsJuice added feature New features and removed feature New features labels Jul 6, 2023
@weykon
Copy link
Contributor

weykon commented Jul 7, 2023

what means v-cursor?
can you explain more information for it ?

the 2 I think I can help, to create a create provider contains default config component

@CatsJuice
Copy link
Owner Author

@weykon

For now in vue, there are only 2 ways to enable this:

  • use updateCursor, initCursor, disposeCursor directly and manage update when component unMounted
  • use useCursor hook, it will auto update when mounted and unMounted

But it's still not convenient enough, you still have to import and call useCursor. And the hook will only manage update when component is disposed. That means if you have a element with v-if it may not working correctly.

With vue directives, we can do update to the element precisely, this can also reduce DOM scanning, as well as better type hints.

So, maybe finally we can register v-cursor and give it default configuration in main.ts

import { vCursorPlugin, IpadCursorConfig } from "ipad-mouse/vue"

const config: IpadCursorConfig = {}
app.use(vCursorPlugin, config)

Then use it directly in SFC:

<script setup>
</script>

<template>
    <!-- detect css display type to decide text | block -->
    <div v-cursor></div>

   <!-- block -->
   <div v-cursor="'block'" />

   <!-- text -->
   <div v-cursor="'text'" />

   <!-- override style -->
   <div v-cursor="{ ? }" />
</template>

It will be more important to design the API than implementing this v-cursor directive.

@weykon
Copy link
Contributor

weykon commented Jul 7, 2023

thanks your explanation!
I do not have Vue experience, I only in react.
but you leave this can be helpful for next people catch on.
I will read source code for react version component code.

@CatsJuice
Copy link
Owner Author

thanks your explanation! I do not have Vue experience, I only in react. but you leave this can be helpful for next people catch on. I will read source code for react version component code.

Yay, feel free to contribute a react implementation!

@CatsJuice CatsJuice added the Vue Vue framework related label Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New features Vue Vue framework related
Projects
None yet
Development

No branches or pull requests

2 participants