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

Callback not always fired #9

Closed
owain opened this issue Nov 7, 2011 · 10 comments
Closed

Callback not always fired #9

owain opened this issue Nov 7, 2011 · 10 comments

Comments

@owain
Copy link

owain commented Nov 7, 2011

If you swipe very quickly several times it seems like the transition end event doesn't get fired (assuming because the actual transition doesn't fire?). This can be seen in the example below (mobile safari doesn't seem to like jsfiddle), everytime the callback is called we prepend to the list with the index. Press on the next link slowly and you see all callbacks, press quickly and you see we miss some indexes:

http://jsfiddle.net/4a2yy/3/

A hacky workaround is to call the callback at the end of the swipe function. I did this in the demo below, calling it within a setTimeout as otherwise it effects how smooth the transition appears in mobile safari.

http://jsfiddle.net/VecTR/9/

@thebird
Copy link
Owner

thebird commented Nov 7, 2011

Yea the transition end function doesn't fire if you begin transitioning again before its complete, which makes sense I guess. A possible solution could be to provide another callback that fires on change of slide?

Do you have a specific use case that needs a change of slide callback every time?

@owain
Copy link
Author

owain commented Nov 7, 2011

Yeah that would work.

I'm using swipe to make a paged result set. So basically I load a dataset and render a subset e.g 10 pages worth of data, render 3 pages of data and as the user swipes to the next page I pre-render the next page ready for when they swipe. So I need to know every time there is a slide.

I currently calculate if it is a forward or back slide too, might be nice to have this as part of the callback params or something?

Saying that, the simplicity of the script is it's strength so I wouldn't want to clog it up with unneeded functionality. Nice work btw!

@bcolflesh
Copy link

owilliams, is the paged result set logic you mentioned above available as public code anywhere? I need something similar and haven't found a good example using Swipe.

@owain
Copy link
Author

owain commented Nov 23, 2011

I'm afraid it's not, it's part of a commercial product. It has some other dependancies on other libraries too (mainly backbone) and isn't very standalone at the moment. I may be able to make it available at some point, but not any time soon I'm afraid.

If you want any pointers then fire me a message.

@bcolflesh
Copy link

Understood - thanks for the reply!

@thebird
Copy link
Owner

thebird commented Dec 12, 2011

Fellas,

What if I make a second callback in the library, like pre-animation? It would fire when any movement has been determined to be a valid swipe to a next, prev slide. Let me know your thoughts.

@owain
Copy link
Author

owain commented Dec 12, 2011

Yeah that should work. I guess you'd need to rename the callback options to be more descriptive too.

It could be argued though that transition end callback isn't needed if you're able to add your own transitionend listener on the element?

@mech
Copy link

mech commented Jan 30, 2012

Yea, I also using this swipe to get paginated pay-slip kind of HR app. For example, on initial children I have 12 months of payslips for year 2011, then when the guy swipe to almost the end like in Feb 2011, I will want to remote load the previous years additional 12 months of payslips for year 2010.

Right now the children detection is not "live" if I am not wrong. Is there a way to make use of delegation a.k.a the jQuery's live way of detecting children?

@thebird
Copy link
Owner

thebird commented Feb 22, 2012

Swipe2 will have a callback function (immediately after the swipe) and a transitionEnd function (after animation) :)

Feel free to start testing it out here

@thebird thebird closed this as completed Feb 22, 2012
@mech
Copy link

mech commented Feb 23, 2012

Thanks for this :)

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

4 participants