appronto / DataviewLoader

A simple widget to place a loading gif when content is loaded on the page.
Apache License 2.0
4 stars 5 forks source link

Behaviour for heavy pages and hidden elements; code cleanup #2

Closed JelleDekker closed 7 years ago

JelleDekker commented 7 years ago

Updated behaviour:

Cleanup:

JelleDekker commented 7 years ago

Update regarding previous pull request, found out that there was an error in processing the MF callback, that's fixed now.

joelvdgraaf commented 7 years ago

Thanks for your work! I really appreciate it! To have better code and new functions I wasn't aware off. On a constructional level I don't agree on everything. To replace the properties in a general category 'settings' isn't conform the widget conventions, referring to https://docs.mendix.com/refguide7/common-widget-properties

Because of the complete code replacing I have some questions:

JelleDekker commented 7 years ago

I set _contentShown early because otherwise you risk the content being loaded multiple times when update is called more often (Mendix does this sometimes). Perhaps _loadingStarted or something would be a better name.

I have everything under settings because the amount of options is very small, this makes it easier to configure the widget in the modeler. Behaviour is normally also used for OnChange and OnClick microflows, not for DataSource/Loading MF's.

I use 'this.domNode.offsetParent' to check if the item is rendered on the page or not. If it's in a closed groupbox or tab container this value will be null. See also http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom

joelvdgraaf commented 7 years ago

Hi Jelle. I've tested your solution, but what you say: "It's now possible to run the widget without a MF. Again for heavy pages" isn't working. When I put the widget in a page without a microflow, the widget is showing a loader, but the Mendix loader will come up too. Can you please test this and come with a testproject? Thank you in advance

JelleDekker commented 7 years ago

Hi Joel,

Unfortunately the Mendix loader will always pop-up when it's loading a page and it thinks it takes too long. I haven't found a way to avoid that by loading the page in the background, Mendix simply doesn't have an API for that (it should!).

I've actually tried to load the hidden content in the background (after the visible content was loaded), but as you said, Mendix unfortunately has no way to hide the progress bar when loading a page. The only possible way would be to search the page for it and then hide it, but I thought that to be a too ugly solution.

So what I use the (adapted) version of the widget for is a very heavy page with many groupboxes (could also have been tabs but the our visual design required groupboxes). Then I changed the widget to only trigger the loader when the content is actually displayed (groupbox is opened). In this way the page isn't heavy anymore, each groupbox loads quickly and the page itself also, because the content is broken into pieces which are only loaded when needed.

I should have made the description clearer. With the adaptations you can cut a large page into many small pieces, and it will load much faster even if it's the page that's heavy and not the MF. But only if you make sure (by initially hiding content in closed containers) that the pieces are not loaded all at once.