turn.js icon indicating copy to clipboard operation
turn.js copied to clipboard

how to add page at the front

Open zhangzhzh opened this issue 14 years ago • 6 comments

I use $('selector').turn('addPage', element, 1), but it not work.

zhangzhzh avatar May 18 '12 11:05 zhangzhzh

There are errors as below:

  1. When there is no page in the magazine, the new page don't appear in the magazine after invoking turn('addPage', element, 1) ;

  2. When there is only one page in the magazine, an error of " throw new Error ('"'+page+'" is not a page for range');" occurs after invoking turn('addPage', element, 1);

  3. When there is more pages in the magazine, the old end page lost after invoking turn('addPage', element, 1);

Anybody can help? thanks.

zhangzhzh avatar May 18 '12 13:05 zhangzhzh

@zhangzhzh I saw one problem in the 3rd release when removing a page, but not when adding. The problem of range was solved in the 4th version. I will update the current release to solve the problem. Do you have a code snippet?

blasten avatar May 22 '12 04:05 blasten

I'm having the same problem using version 4.1.0 ... Seems that you have to refresh the number of pages after adding a new one at the front, or the last page will be unreachable (out of range).

$('#magazine')
    .turn('addPage', $('<div />'), 1)
    .turn('pages', $('#magazine').turn('pages')+1);

bongofury avatar Apr 23 '13 10:04 bongofury

@blasten I was wrong, if you do as I descripted above, you'll get something broken when trying to flip the page. The error is :

Uncaught TypeError: Cannot read property 'f' of null turn.js:1913

bongofury avatar Apr 26 '13 09:04 bongofury

@bongofury Yes, this is because the way it was designed, turn.js thinks that you are adding a page to a section that isn't in memory (dynamic pages) instead of a new page. This problem has been fixed in the upcoming update. In other words, the current version only allows to add pages at the end:

$('#magazine')
    .turn('addPage', $('<div />'),  $('#magazine').turn('pages')+1);

blasten avatar May 01 '13 15:05 blasten

So how is this fixed ? Any idea ? Or is this library deprecated?

deepyes02 avatar Feb 15 '23 05:02 deepyes02