Swipe icon indicating copy to clipboard operation
Swipe copied to clipboard

Implement a "render as you need" feature to improve performance

Open parisholley opened this issue 14 years ago • 3 comments

I ended up getting this work somewhat, just need to fork the project and submit a potential implementation. The issue I had, was I was using this library to swipe the entire application, so you advance from one screen to the next. CSS transformations are much faster than using top/left etc, but performance is awful once you hit a large pixel count overall. In my example, the library calculated a total container width of 20k which made leveraging other libraries (such as jquery mobile) very difficult as any other rendering caused pauses.

My solution to this problem was two things. First, I only made "visible" the current slide, previous and next slide. That way, during transitions, it is only rendering 3 slides worth, instead of them all. On transition completion, it would then recalculate what prev/cur/next is, flip visibility and continue. I also had to put a restriction on preventing the user from swiping until the transition completed so they couldn't slide into a hidden one.

For the above to work, I have to absolution position everything instead of using inline, so that when something is display:none, things were positioned as they should. I believe I tried doing visible:none, but it still draws it even if it isn't displayed. Alternatively, we could wrap the content containers again and hide its content so we can maintain position through transitions.

parisholley avatar Jan 05 '12 00:01 parisholley

By "rending as you need", aren't you kinda rebuilding JQtouch or JQM? For example you can cache 'pages' and place them left of right when required. Am I missing something here, or do you only want the slide functionality and just one big 'page' with unlimited slides?

Robbes avatar Jan 06 '12 12:01 Robbes

Yes, just one big slide. In my case, I was building a survey application and with existing frameworks, there is no concept of swiping through pages, simply triggering transition events. Even if this was support else where, performance increases tremendously with this change.Otherwise, the main page of the site should just say "swipejs image viewer" :)

parisholley avatar Jan 06 '12 14:01 parisholley

The upcoming Swipe2 was rebuilt to tackle this issue :)

Feel free to start testing it here

thebird avatar Feb 22 '12 23:02 thebird