Open garbowza opened 10 years ago
Don't remove pages - this is handled automatically - just turn pages to pages - page adding and removal are taken care of - no need to use remove page as far as I can tell. I can understand why you are having problems - when you remove a single page from the index you're creating problems for 2 page viewing -
@alQemist thanks for the response, however I need to dynamically remove pages in the book using the documented removePage function. The problem is that this function seems to be causing errors within subsequent pages of the book.
https://github.com/blasten/turn.js/wiki/Reference#removepage-r3
Can you explain why you need to remove a page ? When you take it upon yourself to remove a page rather than rely upon the built-in page management you assume all responsibility for page display. If you remove one page you upset the page order - books rely on 2 page spreads - or pages in pairs. You need to remove pages in sets of 2 if you want to preserve the proper left page/ right page display
@alQemist my app lets users design and order a photo book, so being able to remove pages they don't want is pretty critical functionality. Since removePage is a documented method, it's strange to assume that it wouldn't function properly. The documentation doesn't mention any restrictions or limitations in its use. This seems like a pretty major bug to me. Am I missing something?
https://github.com/blasten/turn.js/wiki/Reference#removepage-r3
No this is perfectly expected result if you understand the design model. You need to separate in your mind the concept of design functions from the display functions. Basically you can allow someone to add and remove pages but once any edits are made you need to recreate the array of pages - the data that defines your page sources and then reload the book
Is there a method to reload the book (using the updated data source), or do I need to completely destroy the existing book and reload it (essentially refreshing the page), and then open it to their current page? That seems like it'd be a poor UX - is there a better way to just reload the data for the pages in view to get it synced up again?
What is the removePage method used for then?
removePage is used for removing a page that is beyond the range of pre-loaded pages. So as you navigate the book previous pages are removed and new subsequent pages are added so there is always a constant number of pages in the "stack" You might consider not removing a currently viewed page but instead change its source to a blank HTML template page which indicates it has been deleted and waiting to be replaced with new content.
The challenge of that proposed approach for our app is that for many people it's important to see which photos align with each other in a single view (separated by the binding), so showing a blank page for a deleted one will result in the rest of the pages to have incorrect associations.
Would it be possible to loop through each page loaded in memory and swap out the page for new HTML accurately reflecting the updated page order?
Seems to me that would work.
@alQemist do you know if there's a supported way to refresh the view to refill the pages with updated data, without having to destroy and recreate the book?
I'm running into an issue with removePage, which breaks the subsequent pages in my book. They become duplicated, or the even/odd gets out of sync (maybe a z-index issue?).
I can duplicate this on your Steve Jobs book as well.