欢迎各位兄弟 发布技术文章
这里的技术是共享的
var speed = 22; //摇一摇程序,建议值在20-25之间;
var x = y = z = lastX = lastY = lastZ = 0; //默认值
window.addEventListener('devicemotion', function() {
var acceleration = event.accelerationIncludingGravity;
x = acceleration.x;
y = acceleration.y;
if (Math.abs(x - lastX) > speed || Math.abs(y - lastY) > speed) {
//window.location.href = 'http://pkt.zoosnet.net/LR/Chatpre.aspx?id=PKT40658297&lng=cn' //摇动之后的行为,链接可以是报名、咨询、电话支持tel:+号码
openZoosUrl();return false;
}
lastX = x;
lastY = y
}, false)
}