Blame view

src/components/spin/index.js 649 Bytes
297648f1   梁灏   fixed #1063
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  import Spin from './spin.js';
  
  let spinInstance;
  
  function getSpinInstance (render = undefined) {
      spinInstance = spinInstance || Spin.newInstance({
          render: render
      });
  
      return spinInstance;
  }
  
  function loading (options) {
      const render = ('render' in options) ? options.render : undefined;
      let instance  = getSpinInstance(render);
  
      instance.show(options);
  }
  
  Spin.show = function (props = {}) {
      return loading(props);
  };
  Spin.hide = function () {
      if (!spinInstance) return false;
  
      const instance = getSpinInstance();
  
      instance.remove(() => {
          spinInstance = null;
      });
  };
  
7fa943eb   梁灏   init
33
  export default Spin;