import{_ as p,M as c,p as i,q as l,Q as n,t as s,N as t,V as e,a1 as o}from"./framework-2d0bbdc3.js";const d={},u=n("h1",{id:"use",tabindex:"-1"},[n("a",{class:"header-anchor",href:"#use","aria-hidden":"true"},"#"),s(" use")],-1),r=o(`<h2 id="webloading" tabindex="-1"><a class="header-anchor" href="#webloading" aria-hidden="true">#</a> <code>WebLoading</code></h2><blockquote><p>Whether it is <code>DOM</code>, <code>FULL </code>or <code>MINI </code>, it will eventually go to <code>WebLoading</code>.</p></blockquote><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> LoadingType <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;web-loading/src/types.d&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> initLoading <span class="token keyword">from</span> <span class="token string">&#39;web-loading/src/loading&#39;</span>
<span class="token keyword">let</span> webLoading<span class="token operator">:</span>LoadingType <span class="token operator">=</span> <span class="token function">initLoading</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>webLoading<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p><code>LoadingType</code>：<code>loading</code>、<code>resize</code>、<code>close</code>、<code>update</code>、<code>getOptions</code>、<code>getLoadingId</code>。</p></blockquote><h3 id="loading" tabindex="-1"><a class="header-anchor" href="#loading" aria-hidden="true">#</a> loading</h3><blockquote><p>Start the animation<code>loading</code>。</p></blockquote><ul><li><p>Parameters:</p><ul><li><code>dom:HTMLElement</code></li><li><code>options?:OptionsType</code></li></ul></li><li><p>Return: void</p></li></ul><blockquote><p>When the <code>loading</code> function is called, it will first check whether the <code>loadingId</code> exists (whether it is still being drawn). Only when there is no drawing status can it be started.</p><p>The <code>loading</code> parameter 2 can override the <code>options</code> of the initialization <code>initLoading </code>.</p></blockquote><h3 id="resize" tabindex="-1"><a class="header-anchor" href="#resize" aria-hidden="true">#</a> resize</h3><blockquote><p>Recalculate and draw the <code>loading</code> size.</p></blockquote><ul><li>Parameter: None</li><li>Return: void</li></ul><blockquote><p><code>Resize</code>will retrieve the size and redraw from the bound<code>HtmlElement</code>. This function will not re-instance<code>WebLoading</code>and<code>loading</code>business scenarios. For example,<code> window. addEventListener (</code>resize<code>, loading. resize) </code>may be used.</p></blockquote><h3 id="close" tabindex="-1"><a class="header-anchor" href="#close" aria-hidden="true">#</a> close</h3><blockquote><p>close<code>loading。</code></p></blockquote><ul><li>Parameter: None</li><li>Return: void</li></ul><blockquote><p><code>close</code> will first clear all <code>stores</code> and other records of<code>WebLoading</code>, and stop the<code>requestAnimationFrame</code>call, and finally clear the relevant elements according to<code>delayInto</code>. During the closing process,<code>WebLoading</code>will use<code>hookCall</code>to trigger the<code>hook</code>to close <strong>hook function</strong> (<code>BEFORE _COLSE</code>: before closing,<code>COLSED</code>: after closing, that is, after clearing the elements) to facilitate the drawing of <strong>model</strong>.</p></blockquote><h3 id="update" tabindex="-1"><a class="header-anchor" href="#update" aria-hidden="true">#</a> update</h3><blockquote><p>Draw <code>model</code> dynamically. <a href="#Public">Public Configuration</a> cannot be modified dynamically.</p></blockquote><ul><li>Parameter: <ul><li><code>options?:OptionsType</code></li></ul></li><li>Return:void</li></ul><blockquote><p>The update function does not re-instance <code>WebLoading</code>, and re-draws<code>model</code>through the parameter<code> options</code>. The business scenario is similar to <code>loading</code>, but <code>loading</code> initializes<code>WebLoading</code>every time. Only when it is closed can the corresponding business be implemented. Therefore,<code>update</code>is recommended in the dynamic rendering<code>model</code>business scenario.</p></blockquote><h3 id="getoptions" tabindex="-1"><a class="header-anchor" href="#getoptions" aria-hidden="true">#</a> getOptions</h3><blockquote><p>Get the current options configuration.</p></blockquote><ul><li><p>Parameter: None</p></li><li><p>Return:</p><ul><li><code>options:OptionsType</code></li></ul></li></ul><h3 id="getloadingid" tabindex="-1"><a class="header-anchor" href="#getloadingid" aria-hidden="true">#</a> getLoadingId</h3><blockquote><p>obtain <code>loadingId</code>。</p></blockquote><ul><li><p>Parameter: None</p></li><li><p>Return:</p><ul><li><code>loadingId:string | null</code></li></ul></li></ul><blockquote><p>The <code>loadingId </code>will be assigned a value after initialization, and will be assigned a value of<code>null</code>after<code>close</code>is closed. Therefore, if<code>loadingId</code>is<code> null</code>, there is currently no drawing status, otherwise the opposite is true.</p></blockquote><h2 id="options" tabindex="-1"><a class="header-anchor" href="#options" aria-hidden="true">#</a> options</h2><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> <span class="token constant">MODEL_TYPES</span> <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;web-loading/src/utils&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> initLoading <span class="token keyword">from</span> <span class="token string">&#39;web-loading/src/loading&#39;</span>
<span class="token keyword">let</span> webLoading <span class="token operator">=</span> <span class="token function">initLoading</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    model<span class="token operator">:</span><span class="token constant">MODEL_TYPES</span><span class="token punctuation">.</span><span class="token constant">GEAR</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="public" tabindex="-1"><a class="header-anchor" href="#public" aria-hidden="true">#</a> Public</h3><table><thead><tr><th>attribute</th><th>type</th><th>default</th><th>remarks</th></tr></thead><tbody><tr><td><code>html?:</code></td><td><code>string</code></td><td><code>&#39;&#39;</code></td><td>**Html ** loading method (<strong>priority is higher than custom</strong>)</td></tr><tr><td><code>custom?:</code></td><td><code>typeof BaseModel or null</code></td><td><code>null</code></td><td>Custom <strong>model</strong> (<strong>has the highest priority</strong>)</td></tr><tr><td><code>type?:</code></td><td><code>LOADING_TYPES</code></td><td><code>LOADING_TYPES.DOM</code></td><td>Start mode</td></tr><tr><td><code>miniClass?:</code></td><td><code>string or null or undefined</code></td><td><code>mini</code></td><td>Start by<strong>MINI</strong>is<strong>class</strong></td></tr><tr><td><code>model?:</code></td><td><code>MODEL_TYPES</code></td><td><code>MODEL_TYPES.RING</code></td><td>Model module</td></tr><tr><td><code>text?:</code></td><td><code>string</code></td><td><code>加载中...</code></td><td>Font content</td></tr><tr><td><code>textGap?:</code></td><td><code>number</code></td><td><code>8</code></td><td>Font spacing</td></tr><tr><td><code>fontSize?:</code></td><td><code>number</code></td><td><code>12</code></td><td>Font size</td></tr><tr><td><code>fontFamily?:</code></td><td><code>string</code></td><td><code>Microsoft YaHei</code></td><td>Font type</td></tr><tr><td><code>delay?:</code></td><td><code>number</code></td><td><code>65</code></td><td>Animation delay</td></tr><tr><td><code>delayInto?:</code></td><td><code>number</code></td><td><code>520</code></td><td>Turn enter/off animation delay</td></tr><tr><td><code>optimization?:</code></td><td><code>boolean</code></td><td><code>false</code></td><td>Optimization processing (not supported temporarily)</td></tr><tr><td><code>zIndex?:</code></td><td><code>string</code></td><td><code>2001</code></td><td>Loading level</td></tr><tr><td><code>themeColor?:</code></td><td><code>string</code></td><td><code>rgba(64,158,255,1)</code></td><td>Theme color</td></tr><tr><td><code>bgColor?:</code></td><td><code>string</code></td><td><code>rgba(0, 0, 0, 0.8)</code></td><td>Background color</td></tr><tr><td><code>shadowColor?:</code></td><td><code>string</code></td><td><code>rgba(64,158,255,0.6)</code></td><td>Shadow color</td></tr><tr><td><code>shadowOffsetX?:</code></td><td><code>number</code></td><td><code>2</code></td><td>Shadow X</td></tr><tr><td><code>shadowOffsetY?:</code></td><td><code>number</code></td><td><code>2</code></td><td>Shadow Y</td></tr><tr><td><code>shadowBlur?:</code></td><td><code>number</code></td><td><code>5</code></td><td>Shadow range</td></tr><tr><td><code>pointerEvents?:</code></td><td><code>boolean</code></td><td><code>false</code></td><td>Event penetration(<strong>DOM</strong>model)</td></tr><tr><td><code>toast?:</code></td><td><code>boolean</code></td><td><code>true</code></td><td>Whether to display a prompt</td></tr></tbody></table><ul><li>LOADING_TYPES</li></ul><table><thead><tr><th>attribute</th><th>enum</th><th>remarks</th></tr></thead><tbody><tr><td>DOM</td><td><code>dom</code></td><td>Element</td></tr><tr><td>FULL</td><td><code>full</code></td><td>Full screen</td></tr><tr><td>MINI</td><td><code>mini</code></td><td>Mobile terminal</td></tr></tbody></table><ul><li>MODEL_TYPES</li></ul>`,34),k=n("h3",{id:"model",tabindex:"-1"},[n("a",{class:"header-anchor",href:"#model","aria-hidden":"true"},"#"),s(" model")],-1),m=o(`<h2 id="custom-model" tabindex="-1"><a class="header-anchor" href="#custom-model" aria-hidden="true">#</a> custom model</h2><h3 id="typescript-item-example" tabindex="-1"><a class="header-anchor" href="#typescript-item-example" aria-hidden="true">#</a> TypeScript Item Example</h3><ul><li>custom</li></ul><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">import</span> <span class="token keyword">type</span> <span class="token punctuation">{</span> OptionsType<span class="token punctuation">,</span> LimitType<span class="token punctuation">,</span> ElementType <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;web-loading/src/types.d&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> BaseModel <span class="token keyword">from</span> <span class="token string">&quot;web-loading/src/draw/model/BaseModel&quot;</span><span class="token punctuation">;</span>
<span class="token comment">// 1?.If options in the model need custom parameters, define options type</span>
<span class="token class-name"><span class="token keyword">interface</span></span> CustomOptionsType <span class="token keyword">extends</span> <span class="token class-name">OptionsType</span> <span class="token punctuation">{</span>
  size<span class="token operator">?</span><span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// 2?.Customize the default parameters of the model (if you do not need to customize the options parameter, you can use OptionsType)</span>
<span class="token comment">// 2.1?. Define default values</span>
<span class="token keyword">let</span> modelDefOptions<span class="token operator">:</span> CustomOptionsType <span class="token operator">=</span> <span class="token punctuation">{</span>
  size<span class="token operator">:</span> <span class="token number">10</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token comment">// 2.2?.Size of limit value</span>
<span class="token keyword">let</span> limits<span class="token operator">:</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span>LimitType<span class="token operator">&gt;</span> <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span>
    key<span class="token operator">:</span> <span class="token string">&quot;size&quot;</span><span class="token punctuation">,</span>
    message<span class="token operator">:</span> <span class="token string">&quot;key &lt; 100&quot;</span><span class="token punctuation">,</span>
    <span class="token function-variable function">limit</span><span class="token operator">:</span> <span class="token punctuation">(</span>key<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> key <span class="token operator">&lt;</span> <span class="token number">100</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token comment">// 3.Custom model class</span>
<span class="token class-name"><span class="token keyword">class</span></span> CustomLoading <span class="token keyword">extends</span> <span class="token class-name">BaseModel<span class="token operator">&lt;</span>CustomOptionsType<span class="token operator">&gt;</span></span> <span class="token punctuation">{</span>
  <span class="token function">constructor</span><span class="token punctuation">(</span>w<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">,</span> h<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">,</span> canvas<span class="token operator">:</span> HTMLCanvasElement<span class="token punctuation">,</span> options<span class="token operator">:</span> Required<span class="token operator">&lt;</span>CustomOptionsType<span class="token operator">&gt;</span><span class="token punctuation">,</span> element<span class="token operator">:</span> ElementType<span class="token punctuation">)</span> <span class="token punctuation">{</span>
   <span class="token keyword">super</span><span class="token punctuation">(</span>w<span class="token punctuation">,</span> h<span class="token punctuation">,</span> canvas<span class="token punctuation">,</span> options<span class="token punctuation">,</span> element<span class="token punctuation">,</span> modelDefOptions<span class="token punctuation">,</span> limits<span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token function">modelDefCall</span><span class="token punctuation">(</span>model<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token comment">//BaseModel initialization success callback (you can do some special initialization operations yourself)</span>
      <span class="token comment">//The model is CustomLoading itself. Here, the initialization default brush fill is red</span>
      model<span class="token punctuation">.</span>ctx<span class="token punctuation">.</span>fillStyle <span class="token operator">=</span> <span class="token string">&quot;red&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 根据周期调用</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>draw<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token function">draw</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// Empty the canvas</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearRect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">let</span> op <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>options<span class="token punctuation">;</span>
    <span class="token comment">// Draw (get the configured custom options parameter here)</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>ctx<span class="token punctuation">.</span><span class="token function">fillRect</span><span class="token punctuation">(</span><span class="token operator">-</span>op<span class="token punctuation">.</span>size <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token operator">-</span>op<span class="token punctuation">.</span>size <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">,</span> op<span class="token punctuation">.</span>size<span class="token punctuation">,</span> op<span class="token punctuation">.</span>size<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>Here is a simple custom drawing of a rectangle</p><ul><li><code>BaseModel</code> is a user-defined inheritance class. If it is introduced globally, the <code>BaseModel</code> attribute is mounted in the <code>window</code>.</li><li>Note: <code>modelDefOptions</code>,<code> limits</code>, <code>modelDefCall</code> are not required parameters</li><li>Here, if the customized <strong>model</strong> does not need the <code>options</code> parameter, you can omit the <strong>1、2</strong> steps.</li></ul></blockquote><ul><li>loading</li></ul><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> LoadingType <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;web-loading/src/types.d&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> initLoading <span class="token keyword">from</span> <span class="token string">&quot;web-loading/src/loading&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> dom <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">querySelector</span><span class="token punctuation">(</span><span class="token string">&quot;xxx&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// configuration parameter</span>
<span class="token keyword">let</span> options<span class="token operator">:</span> CustomOptionsType <span class="token operator">=</span> <span class="token punctuation">{</span>
  custom<span class="token operator">:</span> CustomLoading <span class="token keyword">as</span> <span class="token keyword">typeof</span> BaseModel<span class="token punctuation">,</span>
  size<span class="token operator">:</span> <span class="token number">20</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> webLoading<span class="token operator">:</span> LoadingType <span class="token operator">=</span> <span class="token function">initLoading</span><span class="token punctuation">(</span>options<span class="token punctuation">)</span><span class="token punctuation">;</span>
webLoading<span class="token punctuation">.</span><span class="token function">loading</span><span class="token punctuation">(</span>dom<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="native-html-project-example" tabindex="-1"><a class="header-anchor" href="#native-html-project-example" aria-hidden="true">#</a> Native html project example</h3><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>en<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>UTF-8<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>viewport<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>width=device-width, initial-scale=1.0<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">&gt;</span></span>web-loading<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://cdn.jsdelivr.net/npm/web-loading<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>app<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>item<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>
          id:
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>value<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>001<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>
          user:
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>value<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>use1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
      window<span class="token punctuation">.</span><span class="token function-variable function">onload</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        <span class="token comment">// encapsulation</span>
        <span class="token keyword">let</span> modelDefOptions <span class="token operator">=</span> <span class="token punctuation">{</span>
          <span class="token literal-property property">size</span><span class="token operator">:</span> <span class="token number">10</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">let</span> limits <span class="token operator">=</span> <span class="token punctuation">[</span>
          <span class="token punctuation">{</span>
            <span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;size&#39;</span><span class="token punctuation">,</span>
            <span class="token literal-property property">message</span><span class="token operator">:</span> <span class="token string">&#39;key &lt; 100&#39;</span><span class="token punctuation">,</span>
            <span class="token function-variable function">limit</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">key</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
              <span class="token keyword">return</span> key <span class="token operator">&lt;</span> <span class="token number">100</span>
            <span class="token punctuation">}</span>
          <span class="token punctuation">}</span>
        <span class="token punctuation">]</span>
        <span class="token keyword">class</span> <span class="token class-name">CustomLoading</span> <span class="token keyword">extends</span> <span class="token class-name">BaseModel</span> <span class="token punctuation">{</span>
          <span class="token function">constructor</span><span class="token punctuation">(</span><span class="token parameter">w<span class="token punctuation">,</span> h<span class="token punctuation">,</span> canvas<span class="token punctuation">,</span> options<span class="token punctuation">,</span> store</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">super</span><span class="token punctuation">(</span>w<span class="token punctuation">,</span> h<span class="token punctuation">,</span> canvas<span class="token punctuation">,</span> options<span class="token punctuation">,</span> store<span class="token punctuation">,</span> modelDefOptions<span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token function">modelDefCall</span><span class="token punctuation">(</span><span class="token parameter">model</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
              model<span class="token punctuation">.</span>ctx<span class="token punctuation">.</span>fillStyle <span class="token operator">=</span> <span class="token string">&#39;red&#39;</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
            <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>draw<span class="token punctuation">)</span>
          <span class="token punctuation">}</span>
          <span class="token function">draw</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearRect</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token keyword">let</span> op <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>options
            <span class="token keyword">this</span><span class="token punctuation">.</span>ctx<span class="token punctuation">.</span><span class="token function">fillRect</span><span class="token punctuation">(</span><span class="token operator">-</span>op<span class="token punctuation">.</span>size <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token operator">-</span>op<span class="token punctuation">.</span>size <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">,</span> op<span class="token punctuation">.</span>size<span class="token punctuation">,</span> op<span class="token punctuation">.</span>size<span class="token punctuation">)</span>
          <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// loading</span>
        <span class="token keyword">let</span> docApp <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">querySelector</span><span class="token punctuation">(</span><span class="token string">&#39;#app&#39;</span><span class="token punctuation">)</span>
        <span class="token keyword">const</span> webLoading <span class="token operator">=</span> <span class="token function">initLoading</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
          <span class="token literal-property property">custom</span><span class="token operator">:</span> CustomLoading<span class="token punctuation">,</span>
          <span class="token literal-property property">size</span><span class="token operator">:</span> <span class="token number">20</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span>
        window<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span><span class="token string">&#39;resize&#39;</span><span class="token punctuation">,</span> webLoading<span class="token punctuation">.</span>resize<span class="token punctuation">)</span>
        webLoading<span class="token punctuation">.</span><span class="token function">loading</span><span class="token punctuation">(</span>docApp<span class="token punctuation">)</span>
        <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
          webLoading<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1500</span><span class="token punctuation">)</span>
      <span class="token punctuation">}</span>
    </span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span><span class="token punctuation">&gt;</span></span><span class="token style"><span class="token language-css">
    <span class="token selector">#app</span> <span class="token punctuation">{</span>
      <span class="token property">margin</span><span class="token punctuation">:</span> 12px<span class="token punctuation">;</span>
      <span class="token property">padding</span><span class="token punctuation">:</span> 12px<span class="token punctuation">;</span>
      <span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
      <span class="token property">border</span><span class="token punctuation">:</span> 1px solid gray<span class="token punctuation">;</span>
      <span class="token property">overflow</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
      <span class="token property">border-radius</span><span class="token punctuation">:</span> 5px<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token selector">#app .item</span> <span class="token punctuation">{</span>
      <span class="token property">display</span><span class="token punctuation">:</span> flex<span class="token punctuation">;</span>
      <span class="token property">flex-direction</span><span class="token punctuation">:</span> column<span class="token punctuation">;</span>
      <span class="token property">border</span><span class="token punctuation">:</span> 1px solid gray<span class="token punctuation">;</span>
      <span class="token property">border-radius</span><span class="token punctuation">:</span> 5px<span class="token punctuation">;</span>
      <span class="token property">padding</span><span class="token punctuation">:</span> 10px<span class="token punctuation">;</span>
      <span class="token property">line-height</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
      <span class="token property">margin-bottom</span><span class="token punctuation">:</span> 6px<span class="token punctuation">;</span>
      <span class="token property">height</span><span class="token punctuation">:</span> 60px<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token selector">#app .item .value</span> <span class="token punctuation">{</span>
      <span class="token property">display</span><span class="token punctuation">:</span> inline-block<span class="token punctuation">;</span>
      <span class="token property">min-width</span><span class="token punctuation">:</span> 31px<span class="token punctuation">;</span>
      <span class="token property">min-height</span><span class="token punctuation">:</span> 16px<span class="token punctuation">;</span>
      <span class="token property">font-weight</span><span class="token punctuation">:</span> bold<span class="token punctuation">;</span>
      <span class="token property">color</span><span class="token punctuation">:</span> <span class="token function">rgb</span><span class="token punctuation">(</span>64<span class="token punctuation">,</span> 158<span class="token punctuation">,</span> 255<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  </span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="_1、basemodelparameter" tabindex="-1"><a class="header-anchor" href="#_1、basemodelparameter" aria-hidden="true">#</a> 1、<code>BaseModel</code>parameter</h3><blockquote><p><code>WebLoading </code>will automatically inject relevant parameters when calling<code>custom</code>.</p></blockquote><table><thead><tr><th>parameter</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>w</code></td><td><code>number</code></td><td>Canvas Width</td></tr><tr><td><code>h</code></td><td><code>number</code></td><td>Canvas height</td></tr><tr><td><code>canvas</code></td><td><code>HTMLCanvasElement</code></td><td>Canvas element, <code>BaseModel</code> default and get the context of <code>2d</code>, but you can also get other contexts according to the canvas element</td></tr><tr><td><code>options</code></td><td><code>Required&lt;CustomOptionsType&gt;</code></td><td><code>Options</code> is to adjust <strong>model</strong> parameters, which are divided into <strong>public</strong> parameters and <strong>model</strong> parameters, which will be merged eventually, and <code>Required</code> indicates you The parameter of is not empty (has initial value)</td></tr><tr><td><code>element</code></td><td><a href="#elementtype"><code>ElementType</code></a></td><td>Container element</td></tr><tr><td><code>modelDefOptions?:</code></td><td><code>T</code></td><td>Custom default parameters for <strong>model</strong>(optional)</td></tr><tr><td><code>limits?:</code></td><td><a href="#limittype"><code>Array&lt;LimitType&gt;</code></a></td><td>Custom <strong>model</strong>&#39;s&#39; options &#39;value restriction function (optional)</td></tr><tr><td><code>modelDefCall?:</code></td><td><code>(model: BaseModel&lt;T&gt;) =&gt; void</code></td><td><code>BaseModel</code> initialization completion callback (optional)</td></tr></tbody></table><h3 id="elementtype" tabindex="-1"><a class="header-anchor" href="#elementtype" aria-hidden="true">#</a> <code>ElementType</code></h3><blockquote><p>Inherited<code>HTMLElement</code>。</p></blockquote><table><thead><tr><th>attribute</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>loadingId</code></td><td><code>string or null</code></td><td>Record <code>loading</code> element <code>id</code></td></tr><tr><td><code>$store</code></td><td><a href="#elementtype-store-elementstoretype"><code>ElementStoreType</code></a></td><td><code>loding</code> cache content</td></tr><tr><td><code>HTMLElement attribute...</code></td><td>...</td><td>...</td></tr></tbody></table><h3 id="elementtype-store-elementstoretype" tabindex="-1"><a class="header-anchor" href="#elementtype-store-elementstoretype" aria-hidden="true">#</a> <code>ElementType.$store:ElementStoreType</code></h3><blockquote><p>When drawing <strong>model</strong>, you need to use some <strong>states</strong> of <code>WebLoading</code>.</p></blockquote><table><thead><tr><th>attribute</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>options</code></td><td><code>OptionsType</code></td><td>Save the final merged <code>options</code> parameter</td></tr><tr><td><code>animationId</code></td><td><code>number or undefined</code></td><td>Record <code>animation</code> status</td></tr><tr><td><code>loadingId</code></td><td><code>string or null</code></td><td>Record <code>loading</code> element <code>id</code></td></tr><tr><td><code>hookCall</code></td><td><code>HooksCallType</code></td><td>Hook function of <code>loading </code></td></tr><tr><td><code>model</code></td><td><code>BaseModel or null</code></td><td><strong>model</strong> in use</td></tr></tbody></table><h3 id="elementtype-store-hookcall-hookscalltype" tabindex="-1"><a class="header-anchor" href="#elementtype-store-hookcall-hookscalltype" aria-hidden="true">#</a> <code>ElementType.$store.hookCall:HooksCallType</code></h3><blockquote><p><code>WebLoading</code>The hook function triggered when closing.</p><p><code>HOOKSCALL_KEY</code>Enumeration.</p></blockquote><table><thead><tr><th>attribute</th><th>enum</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>BEFORE_COLSE</code></td><td><code>beforeColse</code></td><td><code>Function</code></td><td>Before closing</td></tr><tr><td><code>COLSED</code></td><td><code>colsed</code></td><td><code>Function</code></td><td>After closing (after deleting elements)</td></tr></tbody></table><p>Take <code>custom</code> as an example</p><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token comment">// Other codes are omitted</span>
<span class="token keyword">class</span> <span class="token class-name">CustomLoading</span> <span class="token keyword">extends</span> <span class="token class-name">BaseModel<span class="token operator">&lt;</span>CustomOptionsType<span class="token operator">&gt;</span></span> <span class="token punctuation">{</span>
    <span class="token function">constructor</span><span class="token punctuation">(</span>w<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">,</span> h<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">,</span> canvas<span class="token operator">:</span> HTMLCanvasElement<span class="token punctuation">,</span> options<span class="token operator">:</span> Required<span class="token operator">&lt;</span>CustomOptionsType<span class="token operator">&gt;</span><span class="token punctuation">,</span> element<span class="token operator">:</span> ElementType<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">super</span><span class="token punctuation">(</span>w<span class="token punctuation">,</span> h<span class="token punctuation">,</span> canvas<span class="token punctuation">,</span> options<span class="token punctuation">,</span> element<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">initOptions</span><span class="token punctuation">(</span>defOptions<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>draw<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>store<span class="token punctuation">.</span>hookCall<span class="token punctuation">.</span><span class="token function">beforeColse</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
            <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Before closing&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>store<span class="token punctuation">.</span>hookCall<span class="token punctuation">.</span><span class="token function">colsed</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
            <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;After closing&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">draw</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> op <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>options<span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>ctx<span class="token punctuation">.</span><span class="token function">fillRect</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> op<span class="token punctuation">.</span>size<span class="token punctuation">,</span> op<span class="token punctuation">.</span>size<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="limittype" tabindex="-1"><a class="header-anchor" href="#limittype" aria-hidden="true">#</a> <code>LimitType</code></h3><blockquote><p>Limit the range of <code>options</code> parameter values.</p></blockquote><table><thead><tr><th>attribute</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>key</code></td><td><code>string</code></td><td>The <code>options</code> attribute that needs to be restricted</td></tr><tr><td><code>message</code></td><td><code>string</code></td><td>Prompt for exceeding the limit</td></tr><tr><td><code>limit</code></td><td><code>(key: any) =&gt; boolean</code></td><td>Restricted operation</td></tr></tbody></table><h3 id="_2、basemodel-function" tabindex="-1"><a class="header-anchor" href="#_2、basemodel-function" aria-hidden="true">#</a> 2、<code>BaseModel</code> function</h3><blockquote><p><code>BaseModel</code>The built-in function is mainly for user <strong>extension model</strong> rendering</p></blockquote><table><thead><tr><th>function</th><th>return</th><th>remarks</th></tr></thead><tbody><tr><td><code>initContextCall</code></td><td><code>void</code></td><td><a href="#basemodel-initcontextcall">initContextCall</a></td></tr><tr><td><code>run</code></td><td><code>void</code></td><td><a href="#basemodel-run">run</a></td></tr><tr><td><code>clearRect</code></td><td><code>void</code></td><td><a href="#basemodel-clearrect">clearRect</a></td></tr><tr><td><code>drowRadiusRect</code></td><td><code>void</code></td><td><a href="#basemodel-drowradiusrect">drowRadiusRect</a></td></tr><tr><td><code>drawText</code></td><td><code>void</code></td><td><a href="#basemodel-drawtext">drawText</a></td></tr><tr><td><code>clearAnimationFrame</code></td><td><code>void</code></td><td><a href="#basemodel-clearanimationframe">clearAnimationFrame</a></td></tr></tbody></table><h3 id="basemodel-initcontextcall" tabindex="-1"><a class="header-anchor" href="#basemodel-initcontextcall" aria-hidden="true">#</a> <code>BaseModel:initContextCall</code></h3><blockquote><p><code>BaseModel </code> Initialize the custom canvas property (triggered during inheritance).</p></blockquote><table><thead><tr><th>参数</th><th>类型</th><th>备注</th></tr></thead><tbody><tr><td><code>modelDefOptions?:</code></td><td><code>T</code></td><td>Customize the default <code>options</code> value of <strong>model</strong>.</td></tr><tr><td><code>limits?:</code></td><td><code>Array&lt;LimitType&gt;</code></td><td>Customize the limit range of the <code>options</code> value of <strong>model</strong>.</td></tr><tr><td><code>modelDefCall?:</code></td><td><code>BaseModel&lt;T&gt;</code></td><td><code>BaseModel </code> initialization completion callback.</td></tr></tbody></table><h3 id="basemodel-run" tabindex="-1"><a class="header-anchor" href="#basemodel-run" aria-hidden="true">#</a> <code>BaseModel:run</code></h3><blockquote><p>The <code>requestAnimationFrame</code> is delayed according to the <code>options.delay</code>.</p></blockquote><table><thead><tr><th>parameter</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>fun</code></td><td><code>Function</code></td><td>If it is loading before calling, the last state will be cleared.</td></tr></tbody></table><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
    <span class="token comment">// Triggered according to options.delay</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="basemodel-clearrect" tabindex="-1"><a class="header-anchor" href="#basemodel-clearrect" aria-hidden="true">#</a> <code>BaseModel:clearRect</code></h3><blockquote><p>Empty the canvas.</p></blockquote><table><thead><tr><th>parameter</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>x?:</code></td><td><code>number</code></td><td>Empty starting point X</td></tr><tr><td><code>y?:</code></td><td><code>number</code></td><td>Empty starting point Y</td></tr><tr><td><code>w_r?:</code></td><td><code>number</code></td><td>Empty end X (width), in case of circular emptying <code>w_ R</code> is <strong>radius</strong></td></tr><tr><td><code>h?:</code></td><td><code>number</code></td><td>Empty end Y (height)</td></tr></tbody></table><ul><li>Empty all</li></ul><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearRect</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><blockquote><p>Considering that the drawing area may exceed the default width and height, emptying all will empty <strong>twice</strong> the width and height.</p></blockquote><ul><li>Custom Emptying</li></ul><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearRect</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">100</span><span class="token punctuation">,</span><span class="token number">100</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><blockquote><p>Emptying starts at the coordinates of <code>x=0, y=0</code> and ends at <code>x=100, y=100</code>.</p></blockquote><ul><li>Empty circular area</li></ul><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearRect</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><blockquote><p>Empty the area with <code>x=0, y=0</code> and radius of <code>10</code>.</p></blockquote><h3 id="basemodel-drowradiusrect" tabindex="-1"><a class="header-anchor" href="#basemodel-drowradiusrect" aria-hidden="true">#</a> <code>BaseModel:drowRadiusRect</code></h3><blockquote><p>Draw a rectangle with rounded corners.</p></blockquote><table><thead><tr><th>parameter</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>x</code></td><td><code>number</code></td><td>Start X</td></tr><tr><td><code>y</code></td><td><code>number</code></td><td>Start Y</td></tr><tr><td><code>w</code></td><td><code>number</code></td><td>End X (width)</td></tr><tr><td><code>h</code></td><td><code>number</code></td><td>End Y (height)</td></tr></tbody></table><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">drowRadiusRect</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span>
<span class="token comment">// Need to draw by yourself</span>
<span class="token keyword">this</span><span class="token punctuation">.</span>ctx<span class="token punctuation">.</span><span class="token function">fill</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>Draw a rectangle with <code>x=0, y=0</code> width and height of <code>100</code> and rounded corners of <code>10</code>.</p></blockquote><h3 id="basemodel-drawtext" tabindex="-1"><a class="header-anchor" href="#basemodel-drawtext" aria-hidden="true">#</a> <code>BaseModel:drawText</code></h3><blockquote><p>Draw default text.</p></blockquote><table><thead><tr><th>parameter</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>params?:</code></td><td><a href="#basemodel-drawtext-drawtextparamstype"><code>DrawTextParamsType</code></a></td><td>Draw text parameters</td></tr></tbody></table><h3 id="basemodel-drawtext-drawtextparamstype" tabindex="-1"><a class="header-anchor" href="#basemodel-drawtext-drawtextparamstype" aria-hidden="true">#</a> <code>BaseModel:drawText.DrawTextParamsType</code></h3><table><thead><tr><th>parameter</th><th>type</th><th>default</th><th>remarks</th></tr></thead><tbody><tr><td><code>esGap</code></td><td><code>number</code></td><td><code>0</code></td><td>Extra text gap (textGap+fontSize)</td></tr><tr><td><code>x</code></td><td><code>number</code></td><td><code>0</code></td><td>X-axis</td></tr><tr><td><code>text</code></td><td><code>string</code></td><td><code>加载中...</code></td><td>text</td></tr><tr><td><code>textColor</code></td><td><code>string</code></td><td><code>rgba(64,158,255,1)</code></td><td>text color</td></tr></tbody></table><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">drawText</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="basemodel-clearanimationframe" tabindex="-1"><a class="header-anchor" href="#basemodel-clearanimationframe" aria-hidden="true">#</a> <code>BaseModel:clearAnimationFrame</code></h3><blockquote><p>Empty (stop)<code>requestAnimationFrame</code>。</p></blockquote><table><thead><tr><th>parameter</th><th>type</th><th>remarks</th></tr></thead><tbody><tr><td><code>id</code></td><td><code>number</code></td><td><code>animationId</code></td></tr></tbody></table><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearAnimationFrame</span><span class="token punctuation">(</span>element<span class="token punctuation">.</span>$store<span class="token punctuation">.</span>animationId<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><blockquote><p>The ID passed in is <code>id</code> returned by <code>requestAnimationFrame</code> , and <code>WebLoading</code> has been saved in the store.</p></blockquote><h3 id="_3、basemodel-technique" tabindex="-1"><a class="header-anchor" href="#_3、basemodel-technique" aria-hidden="true">#</a> 3、<code>BaseModel</code> technique</h3><h3 id="dynamic-options" tabindex="-1"><a class="header-anchor" href="#dynamic-options" aria-hidden="true">#</a> Dynamic options</h3><blockquote><p>Whether it is initialization or in the <code>run</code> function, modifying <code>options</code> is real-time and dynamic, which can control the delay time triggered by<code>requestAnimationFrame</code>to be irregular.</p></blockquote><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
    <span class="token comment">// Dynamic modification of delay will affect the trigger of run function</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>options<span class="token punctuation">.</span>delay <span class="token operator">=</span> <span class="token number">10</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="html-configuration-method" tabindex="-1"><a class="header-anchor" href="#html-configuration-method" aria-hidden="true">#</a> Html configuration method</h2><blockquote><p>Add <strong>html</strong> configuration to <code>options</code>, which has priority over <strong>model</strong> and <code>custom</code>.</p></blockquote><h3 id="initialization" tabindex="-1"><a class="header-anchor" href="#initialization" aria-hidden="true">#</a> initialization</h3><div class="language-typescript line-numbers-mode" data-ext="ts"><pre class="language-typescript"><code><span class="token keyword">import</span> initLoading <span class="token keyword">from</span> <span class="token string">&#39;web-loading/src/loading&#39;</span>
<span class="token keyword">let</span> webLoading <span class="token operator">=</span> <span class="token function">initLoading</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    html<span class="token operator">:</span><span class="token template-string"><span class="token template-punctuation string">\`</span><span class="token string">&lt;div class=&quot;spinner&quot;&gt;
    &lt;svg viewBox=&quot;25 25 50 50&quot; class=&quot;circular&quot;&gt;
        &lt;circle stroke-miterlimit=&quot;10&quot; stroke-width=&quot;3&quot; fill=&quot;none&quot; r=&quot;20&quot; cy=&quot;50&quot; cx=&quot;50&quot; class=&quot;path&quot;&gt;&lt;/circle&gt;
    &lt;/svg&gt;
&lt;/div&gt;</span><span class="token template-punctuation string">\`</span></span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p><strong>Html</strong> priority is higher than <strong>custom</strong>.</p></blockquote><h3 id="css-animation" tabindex="-1"><a class="header-anchor" href="#css-animation" aria-hidden="true">#</a> Css animation</h3><div class="language-css line-numbers-mode" data-ext="css"><pre class="language-css"><code><span class="token selector">.spinner</span> <span class="token punctuation">{</span>
  <span class="token property">--red</span><span class="token punctuation">:</span> #d62d20<span class="token punctuation">;</span>
  <span class="token property">--blue</span><span class="token punctuation">:</span> #0057e7<span class="token punctuation">;</span>
  <span class="token property">--green</span><span class="token punctuation">:</span> #008744<span class="token punctuation">;</span>
  <span class="token property">--yellow</span><span class="token punctuation">:</span> #ffa700<span class="token punctuation">;</span>
  <span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
  <span class="token property">width</span><span class="token punctuation">:</span> 60px<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token selector">.spinner:before</span> <span class="token punctuation">{</span>
  <span class="token property">content</span><span class="token punctuation">:</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">;</span>
  <span class="token property">display</span><span class="token punctuation">:</span> block<span class="token punctuation">;</span>
  <span class="token property">padding-top</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token selector">.circular</span> <span class="token punctuation">{</span>
  <span class="token property">animation</span><span class="token punctuation">:</span> rotate73451 2s linear infinite<span class="token punctuation">;</span>
  <span class="token property">height</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
  <span class="token property">transform-origin</span><span class="token punctuation">:</span> center center<span class="token punctuation">;</span>
  <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
  <span class="token property">position</span><span class="token punctuation">:</span> absolute<span class="token punctuation">;</span>
  <span class="token property">top</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token property">bottom</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token property">left</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token property">right</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token property">margin</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token selector">.path</span> <span class="token punctuation">{</span>
  <span class="token property">stroke-dasharray</span><span class="token punctuation">:</span> 1<span class="token punctuation">,</span> 200<span class="token punctuation">;</span>
  <span class="token property">stroke-dashoffset</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token property">animation</span><span class="token punctuation">:</span> dash0175 1.5s ease-in-out infinite<span class="token punctuation">,</span> color7123 6s ease-in-out infinite<span class="token punctuation">;</span>
  <span class="token property">stroke-linecap</span><span class="token punctuation">:</span> round<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token atrule"><span class="token rule">@keyframes</span> rotate73451</span> <span class="token punctuation">{</span>
  <span class="token selector">100%</span> <span class="token punctuation">{</span>
    <span class="token property">transform</span><span class="token punctuation">:</span> <span class="token function">rotate</span><span class="token punctuation">(</span>360deg<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token atrule"><span class="token rule">@keyframes</span> dash0175</span> <span class="token punctuation">{</span>
  <span class="token selector">0%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke-dasharray</span><span class="token punctuation">:</span> 1<span class="token punctuation">,</span> 200<span class="token punctuation">;</span>
    <span class="token property">stroke-dashoffset</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">50%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke-dasharray</span><span class="token punctuation">:</span> 89<span class="token punctuation">,</span> 200<span class="token punctuation">;</span>
    <span class="token property">stroke-dashoffset</span><span class="token punctuation">:</span> -35px<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">100%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke-dasharray</span><span class="token punctuation">:</span> 89<span class="token punctuation">,</span> 200<span class="token punctuation">;</span>
    <span class="token property">stroke-dashoffset</span><span class="token punctuation">:</span> -124px<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token atrule"><span class="token rule">@keyframes</span> color7123</span> <span class="token punctuation">{</span>
  <span class="token selector">100%, 0%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--red<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">40%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--blue<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">66%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--green<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">80%, 90%</span> <span class="token punctuation">{</span>
    <span class="token property">stroke</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--yellow<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>The class naming should try to isolate external elements.</p></blockquote>`,76);function v(b,h){const a=c("RouterLink");return i(),l("div",null,[u,n("blockquote",null,[n("p",null,[s("The use here takes the introduction separately as an example,"),t(a,{to:"/us/guide/#global-introduction"},{default:e(()=>[s("Global introduction")]),_:1}),s("Use similar.")])]),r,n("p",null,[t(a,{to:"/us/document/model.html#supported-models"},{default:e(()=>[s("Supported models")]),_:1})]),k,n("p",null,[t(a,{to:"/us/document/model.html"},{default:e(()=>[s("Model configuration details")]),_:1})]),m])}const y=p(d,[["render",v],["__file","use.html.vue"]]);export{y as default};
