code: function Shake() {
  
          //feature detect
          this.hasDeviceMotion = 'ondevicemotion' in window;
  
          //default velocity threshold for shake to register
          this.threshold = 15;
  
          //use date to prevent multiple shakes firing
          this.lastTime = new Date();
  
          //accelerometer values
          this.lastX = null;
          this.lastY = null;
          this.lastZ = null;
  
          //create custom event
          if (typeof document.CustomEvent === "function") {
              this.event = new document.CustomEvent('shake', {
                  bubbles: true,
                  cancelable: true
              });
          } else if (typeof document.createEvent === "function") {
              this.event = document.createEvent('Event');
              this.event.initEvent('shake', true, true);
          } else {
            return false;
          }
      }
docs: from :https://github.com/alexgibson/shake.js/blob/master/shake.js
  
   
  摇一摇实现-抽奖游戏
  @global
  @class Shake
  
  @example
  ```html
  <script src="../output/template/common/bdbox/game/shake.js"></script>
  <script>
  window.addEventListener('shake', shakeEventDidOccur, false);
  function shakeEventDidOccur () {
  alert('被摇了');
  }
  </script>
  ```