Book Direct Page

Book Direct page is working with problems.

timeout(.1, () => {
   book.directPage=3
});

it goes to the requested page. But after going, the page is not visible. It is not visible while translating. Could you please check if there is a problem?

In the latest version of ZIM, there is a problem when trying to go to page=0. There is no problem when trying to go to page=1.

Maybe this is not a problem.

Thanks for letting us know, @Ferudun - will take a look now.

A simple Book works as expected when using directPage property:

Agreed - the page numbering is awkward when we start with 1 which shows left and right page to start (page 0 and page 1). The default is 0 which shows a "cover" (page 0) at the right and then page 1 and 2, etc.

With the page numbers, if you get the value it will always be the right hand page. It looks like that is the page you need to go to for directPage to work. So go to page 1, 3, 5, etc.

Let us know if that works. We can add adjusting this to properly handle 0,2,4 as well - in a future version.

I have a 10 page work right now. Only pages 1, 3 and 5 are fine. All even numbers have issues. Pages 7 and 9 also have issues.

Is it possible to add new features to the book? Enlargement feature, etc. When enlarged, the page will not curl, that is, there will be no transition to the next page. But there will be scrolling....

I have now added the book object to the window. I can enlarge it. But when scrolling, the page curls and goes to the next page.

1 Like

You might want to use the radius parameter to make the book corner only work in the corners.

The pageDirect has been patched to properly go to the right page number - we had the wrong equation.

We had num = Math.ceil(num/2)-1 rather than Math.floor(num/2)+1

Radius doesn't work. If I set radius true at the beginning, the page doesn't curl at all. If I set radius true after enlarging the page, it doesn't have any effect.

There is an interesting situation in DirectPage: If the number of pages is 10 (0,1,2,3,4 and 5.) there is no problem when going to pages. There is no problem when going to other pages (6,7,8,9,10) when going to pages for the first time. There is a problem when going again. I will try to show it with a video.

The radius is a number - try 50.

Will take a look at the other issue later on tonight...

For now, perhaps try a simple example - I suspect it is something in your pages that might be conflicting. Here is a simple example to play with https://zimjs.com/test8/pages2.html

STYLE = {width:W/2, color:series(blue, pink, yellow, green, brown, purple)};
// add anything you want to each of these Pages
const page1 = new Page();
const page2 = new Page();
const page3 = new Page();
const page4 = new Page();
const page5 = new Page();
const page6 = new Page();
const page7 = new Page();
const page8 = new Page();
const page9 = new Page();
const page10 = new Page();
STYLE = {}
new Label(1).loc(50,50,page1)
new Label(2).loc(50,50,page2)
new Triangle().center(page4);
new Circle().center(page5);
new Rectangle().center(page6);
new Label(7).loc(50,50,page7)
new Label(8).loc(50,50,page8)
new Label(9).center(page9)
new Label(10).center(page10)
const pages = [page1, page2, page3, page4, page5, page6, page7, page8, page9, page10];
// 0 (default) will show only page 0 at right - like a cover
// 1 will show page 0 and page 1 to start - like an open book


new Button({label:"Test Button",height:150})
    .pos(20,14,RIGHT,BOTTOM,pages[3])
    .tap(function () {


        //alert(pages.length)

        ///// ilk sayfaya gitmek istiyorsan page=0 olamaz
        ///// bunun yerine page=1 olacak.
        //book.directPage=1
        book.directPage=9

        //book.gotoPage(0,0.1)
    });    



const book = new Book(W, H, pages, 1).addTo();

timeout(.1, ()=>{
	book.directPage = 5
});

I added a button to the example you sent. And when it goes to page 9, the problem occurs.

1 Like

Okay... solved. That was tricky. In the end, it was a masking problem - a left over corner mask. Please refresh and try again.

It seems to be fixed. There seems to be a problem only when going to pages 8, 9 and 10.

Yes - there is still an issue. This is very complex code - worked on it a couple hours this morning then another couple here... still broken - will work on it more later - perhaps tomorrow afternoon and let you know. We will get it.

1 Like

Okay, thank you. That's fine for now.

Okay - we solved it. When going to a future page we adjust the registration point to the lower left so it pivots on the way back. When jumping to a page, the previous page registration was not set back to 0,0 so the masked previous page, when positioned at 0,0 was off the top out of view. Very tricky. This was as well as the previous issue which was a page still masked in a corner at the right despite it being positioned at the left. So we set the mask null to solve that. We knew jumping directly to a page was tricky... because we planned the whole book to animate from page to page so the code was quite complex. It is solved now and patched in ZIM 017 and NPM 17.0.3. Let us know how it goes.

2 Likes

Yes, I tested it. It works great. Thank you very much.

1 Like