Jasonette / JASONETTE-Android

📡 Native App over HTTP, on Android
https://www.jasonette.com
Other
1.6k stars 270 forks source link

Close Preload only when html in WebView completes rendering #244

Open NicksonYap opened 6 years ago

NicksonYap commented 6 years ago

Hi, I'm trying to make the WebView transition feel more native compared to a webbrowser

What I was thinking is to show a loading page while the WebView is still rendering

I've tried Preload and it seems to close once the .json has been loaded this causes the Preload page to only show in a split second (flashes real quick)

But what about a loading page when the html in the WebView is still loading?

Code that I've tried:

{
  "$jason": {
    "head": {
      "title": "Web Container Native Transition",
      "actions": {
        "$load": {
          "type": "$set",
          "options": {
            "url": [{
              "{{#if $params && 'url' in $params}}": "{{$params.url}}"
            }, {
              "{{#else}}": "https://www.google.com"
            }]
          },
          "success": {
            "type": "$render"
          }
        },
        "navigate": {
          "type": "$href",
          "options": {
            "url": "file://native_transition.json",
            "options": {
              "url": "{{$jason.url}}"
            },
            "preload": {
              "style": {
                "background": "{{'#' + Math.round((0x1000000 + 0xffffff * Math.random())).toString(16).slice(1)}}"
              },
              "layers": [
                {
                  "type": "label",
                  "text": "Loading...",
                  "style": {
                    "top": "300",
                    "left": "0",
                    "width": "100%",
                    "height": "100",
                    "align": "center",
                    "color": "#ffffff",
                    "size": "12"
                  }
                }
              ]
            }
          }
        }
      },
      "templates": {
        "body": {
          "background": {
            "type": "html",
            "url": "{{$get.url}}",
            "action": {
              "trigger": "navigate"
            }
          }
        }
      }
    }
  }
}