zoukankan      html  css  js  c++  java
  • 摇签 功能

    <div class="fate-draw" onclick="rotate()"></div>
    <audio src="./audio/audio.mp3" id="audio" loop="true"></audio>
    <link rel="stylesheet" type="text/css" href="https://blog-static.cnblogs.com/files/gongxiaoyan/fate.css" /> <script type="text/javascript" src="https://blog-static.cnblogs.com/files/gongxiaoyan/shake.js?v=20200622"></script> <audio src="./audio/audio.mp3" id="audio" loop="true"></audio>
    // 摇签功能
            function rotate() {
                $('.fate-draw').addClass('rotate')
                $('#audio').get(0).load()
                $('#audio').get(0).play()
                setTimeout(() => {
                    $('.fate-draw').removeClass('rotate')
                    $('#audio').get(0).pause()
                    elect.layerflag = true
                }, 1000)
                
            }
            var myShakeEvent = new Shake({
              threshold: 8, // optional shake strength threshold
              timeout: 500 // optional, determines the frequency of event generation
            });
            myShakeEvent.start();
            window.addEventListener('shake', shakeEventDidOccur, false);
            function shakeEventDidOccur() {
              rotate()
            }
             iosGrantedTips()
            function iosGrantedTips(){
                var ua = navigator.userAgent.toLowerCase();
                if(ua.indexOf("like mac os x") > 0){
                  var reg = /os [d._]*/gi;
                  var verinfo = ua.match(reg);
                  var version = (verinfo+"").replace(/[^0-9|_.]/ig,"").replace(/_/ig,".");
                  var arr=version.split(".");
                  $(".aa").text(arr[0]+"."+arr[1]+"."+arr[2])
                  if (arr[0]>12&&arr[1]>2) {  //对13.3以后的版本处理,包括13.3,
                    DeviceMotionEvent.requestPermission()
                    .then(permissionState => {
                    if (permissionState === 'granted') { window.addEventListener('devicemotion', () => {})
                    }
                    }).catch((err)=>{
                      fnLayerBox('由于IOS系统需要手动获取访问动作与方向的权限,为了保证摇签正常运行,请在访问提示中点击允许!');
                      $('.layer_btn').click(function () {
                        DeviceMotionEvent.requestPermission()
                        .then(permissionState => {
                        if (permissionState === 'granted') { window.addEventListener('devicemotion', (e) => {})
                        }}).catch((err)=>{
                          alert('获取授权失败');
                        });
                      
                        $(this).parents('.layer_box').remove();
                      })
                    });
                    
                  }else{  //13.3以前的版本
                    alert('13.3以前的版本');    
                  }
                }
              }
  • 相关阅读:
    linux安装php
    linux安装apache
    linux文件目录结构
    第五篇 -- 学习第四天打卡20190616
    第四篇 -- 学习第三天打卡20190615
    第一篇 -- 《每天读一点经济学常识 》 --于台风
    第三篇 -- 学习第二天打卡20190614
    第二篇--学习第一天打卡20190613
    第一篇--程序员如何学英语
    第二篇--无题
  • 原文地址:https://www.cnblogs.com/gongxiaoyan/p/13576179.html
Copyright © 2011-2022 走看看