Hi Oleg.

I'm sorry, the PageStack simply does not support this model.  It can only work 
like a stack, where pages are added and removed from one end of the list, and 
the existing pages on the stack are unmodifiable while there are other pages 
above them in the stack.

In this case, 'above' actually means 'having greater depth value', indicating 
pages added to the stack more recently.  So, if you have 5 pages on the stack 
and replace above the page that has (_depth == 4) only the single page with 
(_depth > 4) will be removed.  There is no API to remove pages lower in the 
stack, as this is not how a stack works.

I think your application may work better by ignoring the stack entirely.  You 
can use replace to transition to a new page without increasing the page stack 
depth, and the content of your page can be dynamically loaded, so you can 
maintain the logical state of the pages in an external array that you control.  
Perhaps what you need is an array of instantiated Items, which can be loaded 
into your actual Page as required, or dropped from the array when no longer 
wanted.

Thanks,
Matt

________________________________
From: Devel [devel-boun...@lists.sailfishos.org] on behalf of Oleg Linkin 
[maledictusdema...@gmail.com]
Sent: Saturday, September 10, 2016 2:42 PM
To: devel@lists.sailfishos.org
Subject: [SailfishDevel] Remove all pages from stack before specified page


Hello, developers



To prevent infinite page stack depth I want to cut some first pages from stack.

I have 5 pages in stack and when I click on item and begin pushing 6 page to 
stack I want to remove first 4 pages and as result I want to have only 5 and 6 
page in stack.

But I can't do this.



I tried the next:

if (pageStack.depth === 5) {

pageStack.replaceAbove(null, pageStack.find(function(page)

{ return page._depth === 4 }), {},

PageStackAction.Immediate)

}



But in this case I got empty page which I found in find function



and the next:

if (pageStack.depth === 5) {

pageStack.pop(pageStack.find(function(page)

{ return page._depth === 4 }),

PageStackAction.Immediate)

}

Documentation says: "If a page object is specified, all pages above the 
specified page are removed;" but in result it remove only page which found in 
pageStack.find function



How I can do this? Thx!



--

*Sincerely, Oleg Linkin.*





*Jabber: ma...@gentoo.ru <ma...@gentoo.ru> Skype: lord_baskervil Тел.: 
+375-(29)-5539994*
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to