Swipe
Swipe copied to clipboard
performance improvment
Added a function to hide all slides and then show only current, next and prev. It prevents browser crash on iOS when there many slides and the slides are "heavy" (images, filters, styles, etc.). Should help with Issue #269.
Dramatically increased performance for me when rendering more than 20+ elements on a screen on both desktop sites and mobile sites.
fixed ipad crash bug for me! thx!
I don't know why this hasn't been merged yet. Not only did it fix the iOS crash issue, but it results in dramatically improved performance on desktop devices as well. Nice work!
@tn4foxxah - I tested @ronilan fix on IE 10 using Browser Stack and didn't see the issue you noted above.
@cferdinandi Thanks for testing IE10! I'm using this mod: https://github.com/ronilan/Swipe on http://www.placeunit.com inside (@phonegap) and out (web products). So far looks stable :)
I like that you've added a transitionEnd call to the API. VERY useful. I've got the basic version of Swipe going on http://tonyluong.com, with this performance fix added and left/right keyboard arrows in use for slide changes, too. I love how much faster this is than some of the popular jQuery-based sliders I've used.
Hi guys, can you pull the repo from here: https://github.com/alex-b/Swipe and then send me a pull request with your changes so i can merge them? Its a good idea and we need to have it. I think Brad is busy at the moment so we should keep on maintaining his great creation and give other users access to some cool new features. I will try to send this message to other contributors also so we can keep Brad's cool Swipe library alive.
If I knew enough about using Git, I would certainly do so...
Well, it's stopped the iOS crashing (I've got a gallery of 47 images), but now it's added kind of a hiccup to the transition. There's a small pause when I lift my finger during the "touchend" event. Has anyone else noticed this? I'm on an iPad 3. Ah, fixed it by moving the "visibleThree(index, slides);" call out of the "end" function and into the "transitionEnd" function, where apparently it sucks up less processing power.
@megabulk This was a prominent issue for me when I was using the callback function to do most of my JS. When I changed to transitionEnd, I noticed major improvements.
I´m also experiencing this little stop in the transition. I did change the callback function to transitionEnd, but it doesn´t make any difference. Works like a charm in the emulator, but not on the devices (iPad Mini, iPad 4). I´m currently using 30 Slides.
Anything else that might help is highly appreciated.
Like I say, (and if i were better with github, I'd submit a correction to the code), remove line 420 from this patch and add it instead to the
transitionEnd: function(event) {
function
Hope that helps.
It is hard to visualize "stop in the transition", "hiccup to the transition" etc. but I'm using a slightly different hiding method here: https://github.com/ronilan/Swipe and no visible issues (60 slides, iPad).
@megabulk You made my day. Works perfect. Let me buy you a couple beers someday ;-)
@ronilan It seems that swipe.js's "end" function, which is called by the callback option as well as your patch, runs when the user's finger is lifted from the screen. If the callback is at all processor-intensive (as your visibleThree function is), it causes the slide transition to pause briefly. It "hiccups"! Moving that function from swipe.js's internal "end" function to its internal "transitionEnd" function seems to solve that problem. I'm using an iPad 3; maybe later models don't have that problem.
@bocsmedia So glad I could help!
Updated.
To avoid the slides to get visible too late. I would suggest to add visibleThree to end and slide, just before the options.callback, instead of calling it on transitionEnd.
And unless I'm missing something, is the length-const not always slides.length? So, there's no reason to count the slides again ;-)
Implemented as @yckart suggested. @megabulk this may reintroduce the "hiccups" (LMK if it does). @bradbirdsall updated to not loop on setup. We can make hide/show without looping but I'm not sure it will have less "seams" (hide where you slide from, show where you slide to etc.) and it will be harder to maintain.
@ronilan I have made hide/show without looping,however it still has the hiccups, especially in some android devices which low cpu and RAM.