Adding pages dynamically using Turn.js - turnjs

I have about 100 pages, each with an image or a video. While constructing the book I'm calling addPage on all of the 100 pages in a 'for' loop. Since Turn.js keeps only 6 pages in DOM, I assumed it was okay to load it this way. However I've seen examples of loading a few pages in range in an event handler such as when turning. What is the right approach?

Related

How Do You Filter and Sort Data in a CollectionView

I have a CollectionView on a page that is displaying data from a List<> of items. I do sorting and filtering in a code behind on the page by changing the List with LINQ, and then setting the BindingContext of the view, like this:
MyView.BindingContext = FilteredData;
On IOS this works fine, every time, no problem. On Android, I can change the data a few times (it varies - normally three to five) and then the page doesn't display any data. In the debugger I can check and still see the ItemsSource has all of the items, but nothing is displayed. I then "switch" to my other view on the page, which is done by hiding one DataGrid row and showing another, then "switching" back. The data still isn't displayed, but after I do that I can run the code again that does the sorting and filtering and it starts working again - the data is displayed on the page. Not only that, but after I do that, it works every time from that point forward on Android.
I've spent hours trying every thing I can think of to try and find an event or property or anything that would indicate when this problem occurs so I can try and find a work around for it. I'm at a complete loss; wondering if there are suggestions for how to capture and/or fix this problem.
I did find a combination that worked to resolve this issue. I changed the page so that the CollectionView at issue is in the Grid row that has a non-zero (i.e. visible) height when the ContentPage loads. After doing that, the code works as expected. Previously, it was in a Grid.Row whose height was set to an absolute 0 when the page loaded, and then the height was changed to a non-zero value when a button was clicked.
FWIW, this is similar to other issues I've seen with MAUI on Android, where the visibility of certain controls as well as the order in which you modify them can interfere with rendering data binding results.
I solved sorting using a SortedList and made the list items inherit from IComparable, but I don't love the solution because a SortedList is not an ObservableCollection, and because implementing IComparable can be tricky and leaky.

Loading multiple images using http request GWT

I need to load about 400-500 images to the on single page at a time. Is there a quick way of doing so. I can, in fact, load the images using a for loop but that takes very long?
Many thanks in advance
Umesh
As IE is very slow in rendering...please do not add all the images at a time...
As you mentioned the size of images in comment user cannot see all the images at a time..so he must scroll down to see remaining images ...so why can't we use scroll event...
At the first shot loop the first set of images (let say 50) ..from then you can use window scroll event ..
On scrolling you can append next set of 50 images...
This will increase the document load time...not only in internet explorer but also in remaining browsers...

Dynamic number of buttons on GWT UI

I have a MVP type application where I will have a view that contains one or more buttons. The number of buttons is not known till run time and may vary each time the page is rendered. What is the best way to approach this apart from a simple loop that will just display 1 - n number of buttons that are passed to the view?
My suggestion: Add all the buttons on creation and use CSS to hide or show them dynamically. I think this will yield less DOM manipulations and still works the same, also it might produce a simpler code. I currently do it that way using SmartGwt.

Sencha Touch Carousel optimization

I'm trying to optimize a Carousel component and I wanna have only one active item in DOM. It is easy to achieve simply by removing/adding components in the cardswitch event of carousel. But the problem is that my components load some ajax info from server before rendering and it takes time, so it's slow to rerender them on each cardswitch.
Is there any technique to cache created components but at the same time to not add them to DOM?
Actually there is no way to keep items otside the DOM and then put them back, so the only solution I found is to recreate items when the became active. It's actually the way Sencha suggests.
The other interesting technique is the one Sencha implemented in ST2. It actually keeps only 3 items in DOM event if carousel has 100000 items. Check the html in Chrome. Haven't seen this carefully yet, but it's cool and performance is great.

How do I delay page display until JS is done?

I've done the prerequisite searching of stackoverflow and looking on the internet. I suspect that the answer is ' This can't be done. ' but I'm hoping someone here might have a solution.
My page loads fine, but many of my YUI components don't fully load before being displayed. For example, my DataTable will resize itself when displaying or my buttons will appear in their native form and then get YUI-fied.
Is there a way to delay the displaying of the page until all the Javascript is finished (i.e. all my YUI components are finished rendering)? I don't know how this would happen, as a lot of the JS depends on the DOM being present to manipulate it.
Is there a way to delay the displaying
of the page
If I understand correctly you would like to hide it until it's done?
If that's the case I have an idea:
add a wrapper around the element you
want to hide (or use
position:absolute to cover it)
give that div a background which use
the color of the surrounding with a
positive z-index
when all your javascript has loaded remove the
z-index or change the color of the background to transparent
Your javascript code would look like this:
do 1. and 2.
load your js
do 3.
Of course it needs to be synchrone.
As an alternative you could use visibility:hidden / visible on the element itself but I dunno for sure if it's well supported.
Try putting your Javascript in the head section of the page, as if it's near the end of the page, it'll load later (making the first elements load faster). OR, better yet, serve up your Javascript compressed and via a CDN, such as Amazon CloudFront so that it loads quickly.