如何使用Expo React-Native检测震动事件? [英] How to detect shake event with Expo React-Native?
本文介绍了如何使用Expo React-Native检测震动事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以通过Expo检测震动事件?
I would like to know if it's possible to detect shake event with Expo ?
推荐答案
You can use DeviceMotion and adding a event listener for rotationRate
.
rotationRate(对象)-具有对象的设备围绕对象的每个轴的旋转速率,其中包含alpha,beta,gamma键,其中alpha围绕Z轴,beta代表X轴,γ代表Y轴.
rotationRate (object) -- Rotation rates of the device around each of its axes as an object with alpha, beta, gamma keys where alpha is around Z axis, beta for X axis and gamma for Y axis.
使用此功能,您还可以查看用户旋转电话的轴(也许您希望根据摇动方向采取不同的操作).
With this you can also look in what axis the user is rotating the phone (maybe you want different actions depending on the shake direction).
这篇关于如何使用Expo React-Native检测震动事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文