Javascript 将加速度计/陀螺仪值转换为x/y
我正在使用document.mousemove设置渐变动画。我想在带有加速计/陀螺仪的移动设备上使用相同的功能,但我似乎无法转换这些值 我试过各种各样的方程式,但似乎都没法使它起作用 以下是我的JS:Javascript 将加速度计/陀螺仪值转换为x/y,javascript,css,accelerometer,mousemove,gyroscope,Javascript,Css,Accelerometer,Mousemove,Gyroscope,我正在使用document.mousemove设置渐变动画。我想在带有加速计/陀螺仪的移动设备上使用相同的功能,但我似乎无法转换这些值 我试过各种各样的方程式,但似乎都没法使它起作用 以下是我的JS: $(document).mousemove(function(event) { windowWidth = $(window).width(); windowHeight = $(window).height(); mouseXpercentage = Math.roun
$(document).mousemove(function(event) {
windowWidth = $(window).width();
windowHeight = $(window).height();
mouseXpercentage = Math.round(event.pageX / windowWidth * 100);
mouseYpercentage = Math.round(event.pageY / windowHeight * 100);
$('.radial-gradient').css('background', 'radial-gradient(at ' + mouseXpercentage + '% ' + mouseYpercentage + '%, #72c0d4, #03373d)');
});