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

[feature request] 'beforeWalk' callback (esp. for images) #97

Open
azrafe7 opened this issue Nov 3, 2015 · 3 comments
Open

[feature request] 'beforeWalk' callback (esp. for images) #97

azrafe7 opened this issue Nov 3, 2015 · 3 comments

Comments

@azrafe7
Copy link

azrafe7 commented Nov 3, 2015

In my current project it would be very useful to have a callback for when an image has just finished loading/preloading - don't care about video atm - (also, having it only called once per new slide would be great, but not a must!).

My usecase is to process single images before showing them, so a callback would do the trick. In particular I'm trying to change the cover mode based on images' size. I've tried to implement this myself, but probably I'm having timing issues (i.e. images are shown before the preprocess step finishes?!), or maybe I'm doing it wrong. (hooking into 'walk'/etc, f.e., isn't working).
Currently I'm setting the cover mode for the next slide and it works well, but handling correctly the first slide seems to be a problem.

Do you have any suggestions about how to solve this with the current implementation? (or maybe willing to implement the callback?)

Thanks for your work in any case! Impressive!

PS: Ohh... in my local repo I've made vegas('current') return a 'fromSlide' field too, as I needed it in my project to acknowledge where the successive slide is coming from (accounting for next/prev/jump). If you're interested I can make a PR with that. Let me know.

@azrafe7
Copy link
Author

azrafe7 commented Nov 3, 2015

For my case I'm envisioning something along the lines of $elmt.vegas('options').onImageLoad = function(img) { ... };.

Would it be possible/easy to add something like that?

@azrafe7
Copy link
Author

azrafe7 commented Nov 5, 2015

Ok, I've hacked up the _goto function to satisfy my requirements and I'm posting my partial solution here in case someone else might find it helpful. (the whole thing comes after the realization that 'walk' is triggered after all settings like cover, transition, etc. are processed, and I needed to modify those before showing the next slide - yeah, in the aftermath it seems quite trivial, but it took me a couple of days to figure out why my previous approach wasn't working)

https://gist.github.com/azrafe7/8e8f13e66e1b3701f139

(sorry for the indentation :/)

As I said it's rather hackish, and probably has drawbacks that I can't see right now (haven't tested it with video f.e., so not sure it works with that), but it does fulfill the job for my specific usecase ;).

@azrafe7 azrafe7 changed the title [feature request] onLoadCallack (esp. for images) [feature request] 'beforeWalk' callback (esp. for images) Nov 5, 2015
@jaysalvat
Copy link
Owner

Thanks @azrafe7 for those feedbacks.

I will think about it and try to add it properly in vegas in the future.

Thanks again.

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

No branches or pull requests

2 participants