-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
using library without vue-router #15
Comments
I know you can use the $.createIllusoryElement extended methods from the plugin to spell it out, I just figured to make it more automatic using only the directive |
I got it working ugly like here: |
Anyway, everything inside Two caveats:
|
Actually, I'm totally overlooking a probably easier solution: using |
So, unbinding COULD work, but it is a little more work than I have time for right now. You may know better being the author on how it could possibly work... from what I can tell, unbind is always fired, even when the entire component is destroyed (say on a router-view change), so parts of what is happening in the routeGuard COULD be ported over to an unbind potentially, to try and simplify this. The problem I was having was the shift in the mindset of the router guard having a singular event (a route change), to no more singular event (at least, not one as "universal" as a router change, but just a user-defined one in a method... and we're trying to get away from having to explicitly do things), and so doing things like "clear the cache before I start collecting eligible v-shared-elements" was a little more difficult without being explicit... So since we have a bunch of elements unbinding, keeping track of them at that micro level... anyway hopefully you see where I'm going with this... but basically you are keeping track of cache using |
Looks like you've narrowed the problem down. I really like the idea so long as we can pull it off without complicating the current behavior (should be possible from what I can tell). It's hard to really look through the code from my phone but think I've got the gist of what you've done. I'm on the road home right now and I'll play around with it as soon as I'm back. I think there's a lot of cool potential in this! |
Here's an example that works with routing as well (did not test keep-alive, however). Just exposed a method
as well as a method:
Instead of clearing the candidates on snapshot (the router guard in the current version), I clear it on the |
So, the problem with trying to keep After using, I like how the It works with keep-alive method: The basic change from current 2.1.0 version is: I think that's it! I tested it a bit with my stuff, and it works great! |
One minor thing I noticed was what happens when you navigate to another route where the transition actually isn't "moving" anywhere (e.g. from /alt to /alive). I don't think that illusory should try and figure this out, as determining if a transition should happen should not be based on calculation of all of the styles to see if anything has changed (IMO). Sounds problematic anyway? Another alternative would be some disabling attribute. Since disabling is dependent on "from" as well as "to" in the case of router (e.g. when going from /a to /b, I want transition, but from /a to /c I do not), and could be based on other elements, perhaps there is a use for a "disabled" attribute like so: v-shared-element:test="{ The presence of a disabled attribute would disqualify the shared element from the snapshot perhaps? Easier than removing the v-shared-element attribute completely? Basically just a check for Anyway, just a thought, don't mean to overkill this thread. Just bringing it up since I noticed that behavior and was thinking of most efficient way to prevent it. If this is something you think is useful, then let's create a new issue for it. |
Update: there is a possible race condition that causes an issue. The issue is that, in some circumstances, the "new" element will be inserted before the "old" element is unbind, and in some circumstances, the reverse. The problem is that when the new element is inserted first, then the old element unbind fires after, and removes the new element from the map. |
I'm currently testing having
at the top of snapshotCache() method in the last above-mentioned codesandbox example. Also removed the |
That looks really good so far. You also seem pretty close done. I'll be able to help experiment more tomorrow. On a side note, I recently discovered the framer-motion library. I haven't personally used it yet but from the examples it seems really cool. There currently isn't an equivalent for Vue, to my knowledge. Would you be interesting in helping me port it to Vue? (Definitely still keeping this project alive though, so don't worry) |
The work done in this issue so far is definitely just brainstorming, I wouldn't say any concept so far is something I think is ready for a PR. Maybe, I'll take a look at framer-motion. |
After playing with this for a long time and still not getting anything that I'd consider reliable enough to ship, and dealing with some performance issues when many shared-elements are present on a single route, I think is a feature best kept for a separate package. If I find some free time I may work on another directive (or component) that is capable of performing such a task. In the meantime, I'm going to close this issue. |
@justintaddei you still around? this feature look any more doable now with the latest vue 3 changes? |
@719media hey! I'm still around. I've been really busy with work and personal stuff so I haven't had much time to keep up with my projects recently. This is probably doable with a bit of a rewrite. I'm absolutely interested in including this if it's feasible. I plan on looking into this myself at some point. If you would like to work on it, I'd be more than willing to review any MRs. I should have more free time in a month or 2. I'll reopen this issue so it stays on my mind :) |
I look for a library to do exactly that, a shared element transition with a modale and can't find one 😭 |
Any update on this? 😅 |
I was thinking of ways to use the library for transforms that don't involve vue-router. For example, a modal opening that doesn't change the history/url.
For example, imagine the code
And having that work v-shared-element
The text was updated successfully, but these errors were encountered: