Tizen 可穿戴 Web 小部件可见性更改和调试 [英] Tizen Wearable Web Widget visibilityChange and Debug

查看:40
本文介绍了Tizen 可穿戴 Web 小部件可见性更改和调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Tizen 可穿戴 Web Widget 时遇到了一些问题.

我刚刚使用 HTML + JS 创建了一个示例项目,并尝试更新生命周期中描述的事件的页面 -> 加载/可见性更改

示例代码可在以下位置找到:https://github.com/Ryccoo/widget-test/blob/master/widget/StockQuote/js/main.js

当我添加小部件时,我可以看到文本something" -> 表示已成功调用 onload 函数.

但是,滑动到另一个小部件并返回不会触发可见性更改事件,如上所述.

如何在用户滚动到此小部件时正确上传内容?

另一个问题是如何调试 Web 小部件?您无法运行 debug 以使用小部件交互式调试程序(仅适用于 Web 应用程序),当我想向控制台打印某些内容时,我只能看到

<块引用>

网络控制台日志 API(console.log、console.info、console.warn、console.error)已被禁用.要激活它,您应该以调试模式启动项目.

如何在调试模式下启动小部件?

谢谢

解决方案

Tizen Studio 尚不支持 Web Widget 调试功能.

但我已经测试了 Visibility Change 事件的代码,它在我的 Samsung Gear S3 上运行良好.每次我在小部件之间更改时都会调用可见性更改回调.你可以试试这个代码示例:

项目文件夹>小部件文件夹> index.html

<头><meta charset="UTF-8"><link rel="stylesheet" type="text/css" href="css/style.css"><身体><div class="main-container Panel"><div id="可见性">可见性:初始化</div>

<script src="js/main.js"></script></html>

项目文件夹> Widget 文件夹> js > main.js

window.onload = function() {};document.addEventListener('visibilitychange',visibilitychange);函数可见性变化(){if (document.visibilityState === '隐藏') {document.getElementById("Visibility").textContent = "Hidden";} 别的 {document.getElementById("Visibility").textContent = "Visible";}}

I am having some problems with Tizen wearable Web Widgets.

I just created a sample project with HTML + JS and tried to update page on events described in life-cycle -> On load / visibility change

the sample code can be found at: https://github.com/Ryccoo/widget-test/blob/master/widget/StockQuote/js/main.js

When I add widget I can see the text "something" -> meaning that onload function was successfully called.

However swiping to another widget and back does not trigger the visibilityChange event as described.

How do I correctly upload the contents when user scrolls to this widget ?

Another question is just how to debug the web widgets? You cant run debug to interactively debug the program with widgets (only for web apps) and when I want to print something to console I only see

The web console logging API (console.log, console.info, console.warn, console.error) has been disabled. To activate it, you should launch project with Debug mode.

How do I launch the widget in Debug mode ?

Thank you

解决方案

Web Widget Debug feature is not Supported yet on Tizen Studio.

But I've test the code for Visibility Change event, and It worked fine on my Samsung Gear S3. Visibility Change callback is being called every time I change between widgets. You may give this code sample a try:

Project folder > Widget folder> index.html

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="css/style.css">
</head>

<body>
    <div class="main-container Panel">
        <div id="Visibility"> Visibilty: Init </div>
    </div>
  <script src="js/main.js"></script>
</body>

</html>

Project folder > Widget folder> js > main.js

window.onload = function() {

};

document.addEventListener('visibilitychange', visibilitychange);

function visibilitychange() {
    if (document.visibilityState === 'hidden') {
        document.getElementById("Visibility").textContent = "Hidden";
    } else {
        document.getElementById("Visibility").textContent = "Visible";
    }
}

这篇关于Tizen 可穿戴 Web 小部件可见性更改和调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆