Rotarty (ring) on Samsung Tizen Gear S2

为君一笑 提交于 2019-12-13 05:47:14

问题


I have been trying to make use of the rotary (ring) of the Gear S2 on my Tizen web apps.

I did not find any part of the documentation giving a direct example anywhere. How can we make use of the rotary?


回答1:


After reading the Tizen Advanced UI Javascript code, I found what I was looking for.

To simply use the rotary of the S2, please use the following code snippet:

rotaryDetentCallback = function rotaryDetentHandler(e) {
    var direction = e.detail.direction;
    if (direction === "CW") {
        // TODO: do something when rotated clockwise

    } else if (direction === "CCW") {
        // TODO: do something when rotated counter clockwise

    }
};

window.addEventListener("rotarydetent", rotaryDetentCallback);

I hope this will help other fellow developers who are also looking everywhere trying to find it.



来源:https://stackoverflow.com/questions/32992667/rotarty-ring-on-samsung-tizen-gear-s2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!