model

The model configuration will eventually be merged with public configuration.

Supported models

If the custom priority is set to be greater than model, enumerate MODEL_ TYPES

modelenumremarks
GEARGearGear rotation
RINGRingCircular rotation
ZOOMZoomShape deformation
PATTERNPatternMultigraph
CLOCKClockClock
BEANBeanPac-Man
ROLLRollroll
CIRCULARCircularCircular
IMGImgimage
SKELETONSkeletonSkeleton

GEAR

type GearOptionsType

attributetypeDefaultlimitremarks
lineStartnumber10Line end
lineEndnumber16End of line
lineStartSkewnumber0Line end Offset
lineEndSkewnumber0End of line Offset
lineWidthnumber4Linewidth
lineCapCanvasLineCaproundLine style
lineNumnumber10[4-8]Number of lines
directionbooleantrueX Rotation direction: true: clockwise, then reverse

To better control the size of Gear, set lineStart and lineEnd to control the radius or size.

RING

type RingOptionsType

attributetypeDefaultlimitremarks
arcGapnumberMath.PI / 4Ring to ring gap
ringGapnumber10Interval between arcs
lineWidthnumber2Linewidth
ringNumnumber2[1-10]Number of rings
radiusnumber6Ring radius
lineCapCanvasLineCaproundLine style
turnnumber10Rotation angle
ringsTurnArray<number>[Math.PI, Math.PI / 4]length<=ringNumInitial angle of multiple rings
directionbooleantrueDirection: true: positive, then negative

ZOOM

typeZoomOptionsType

attributetypeDefaultlimitremarks
maxSizenumber16>=lineWidthzoom Maximum variation
zoomGapnumber10zomm distance
zoomHeightnumber2zomm Height of
zoomNumnumber5zoom quantity
zoomColorsArray<string>[]zoom Custom colors for
lineCapCanvasLineCaproundLine style
lineWidthnumber10<=maxSizeLinewidth
actionZOOM_ACTIONZOOM_ACTION.SCALEaction
directionbooleantrueDirection: true: positive, then negative

ZOOM.action

enumeration ZOOM_ACTION

attributeenumremarks
SCALEscaleSize change
WAVEwavewave
HEIGHTheightHeight change

PATTERN

Type PatternOptionsType, this module delay cannot be modified.

attributetypeDefaultlimitremarks
chartsArray<PATTERN_CHART>[PATTERN_CHART.ARC, PATTERN_CHART.RECT, PATTERN_CHART.TRIANGLE, PATTERN_CHART.HEART, PATTERN_CHART.POLYGON]Supported graphics
chartSizenumber12[5-24]largeness of the shape of the figure
chartColorsArray<string>['#409EFF', '#67C23A', '#E6A23C', '#F56C6C', '#0960bd']Dynamic color
maxHeightnumber60height

PATTERN.charts

enumeration PATTERN_CHART

attributeenumremarks
RECTrectrect
ARCarcarc
TRIANGLEtriangletriangle
HEARTheartheart
POLYGONpolygonpolygon

CLOCK

typeClockOptionsType

attributetypeDefaultlimitremarks
textTime'time' or 's' or ''''Text display mode: time: mm/dd/yy, s: sec
lineColorsArray<string>['#d4d4d4', '#06ab2d', '#8a0303']length<=3Pointer color
lineCapCanvasLineCaproundLine style
lineWidthnumber12Linewidth
clockSizenumber15Clock size
clockGapnumber4Clock gap
hLinebooleantrueTime pointer display
mLinebooleanfalsePointer display
sLinebooleantrueSecond pointer display

BEAN

typeBeanOptionsType

attributetypeDefaultlimitremarks
beanSize'number'15>=5bean Size
pointLengthnumber16>=5The number of points in the bean

ROLL

Type RollOptionsType, this module delay cannot be modified.

attributetypeDefaultlimitremarks
rollSizenumber16length<=3roll size
showChildbooleantrueShow shadow child
childNumnumber4[4-10]Child shadow quantity
rollGapnumber12Shadow gap
chartROLL_CHARTROLL_CHART.WHEELDisplayed graphics
windmillsArray<string>['#1ab3ea', '#de6834', '#30925d', '#f48ea5']The figure is the blade color of Windmills.
windmillPointColorstring#f2c31fThe middle point color when the graph is Windmills.
fixadbooleanfalseCenter fixed or not

ROLL.chart

enumeration ROLL_CHART

attributeenumremarks
RECTrectrect
WHEELwheelwheel
WINDMILLwindmillwindmill

Circular

typeCircularOptionsType

属性类型默认值备注
arcSizenumber8Circle size
arcGapnumber2Circular gap
arcColorsArray<string>['#ec7546', '#8364a4', '#ff6c6e', '#5bc6ab']Custom color for circles
actionCIRCULAR_ACTIONCIRCULAR_ACTION.COLLISIONaction

Circular.action

enumeration CIRCULAR_ACTION

属性枚举值备注
COLLISIONcollisionmove
ROTATErotaterotate

IMG

typeImageOptionsType

attributetypeDefaultremarks
srcstringWebLoading logopictures linking
widthnumber52image width
heightnumber52Picture height
turnbooleantrueRotation or not

Img creates aHTMLImageElement, so usesrcto be compatible with it.

SKELETON

type SkeletonOptionsType

Skeleton No skeleton is generated for embedded text.

attributetypeDefaultremarks
skeletonColorstringrgb(240, 240, 240)Skeleton default color
skeletonAnimationColorstringrgb(226, 226, 226)Skeleton animation color
radiusnumber5Skeleton fillet
animationbooleantrueShow Animation
deepbooleantruedeep skeleton
appointstring''Specify the element skeleton

SKELETON上拉加载例子

Business scenario: The function is to specify some elements to display the skeleton, such as pull-up loading. Only the last or more module elements need to be dynamically displayed to display the skeleton. At this time, it is recommended to specify the elements.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>web-loading</title>
  </head>
  <script src="https://cdn.jsdelivr.net/npm/web-loading"></script>
  <body>
    <div id="app">
      <div class="list">
        <div class="item">
          <div>
            id:
            <span class="value">001</span>
          </div>
          <div>
            user:
            <span class="value">use1</span>
          </div>
        </div>
        <div class="item">
          <div>
            id:
            <span class="value">002</span>
          </div>
          <div>
            user:
            <span class="value">use2</span>
          </div>
        </div>
        <div class="item">
          <div>
            id:
            <span class="value">003</span>
          </div>
          <div>
            user:
            <span class="value">use3</span>
          </div>
        </div>
      </div>
      <div class="skeleton">
        <div>
          <span>id:</span>
          <span class="value"></span>
        </div>
        <div>
          <span>user:</span>
          <span class="value"></span>
        </div>
      </div>
    </div>
    <script>
      let time = null
      let itemIndex = 3
      window.onload = () => {
        let docApp = document.querySelector('#app')
        let docList = document.querySelector('#app .list')
        let itemDoc = document.querySelector('#app .skeleton')
        const webLoading = initLoading({
          model: 'Skeleton',
          bgColor: '',
          deep: true,
          pointerEvents: true
        })
        window.addEventListener('resize', webLoading.resize)
        docApp.addEventListener('scroll', () => {
          if (docApp.scrollTop + docApp.clientHeight >= docApp.scrollHeight - 60) {
            webLoading.loading(itemDoc)
            clearTimeout(time)
            // simulate loading data
            time = setTimeout(() => {
              ++itemIndex
              docList.innerHTML += `<div class="item">
                <span>
                  id:
                  <b class="value">00${itemIndex}</b>
                </span>
                <span>
                  user:
                  <b class="value">user${itemIndex}</b>
                </span>
              </div>`
              webLoading.close()
            }, 1500)
          }
        })
      }
    </script>
  </body>
  <style>
    #app {
      margin: 12px;
      padding: 12px;
      height: 200px;
      border: 1px solid gray;
      overflow: auto;
      border-radius: 5px;
    }
    #app .item,
    #app .skeleton {
      display: flex;
      flex-direction: column;
      border: 1px solid gray;
      border-radius: 5px;
      padding: 10px;
      line-height: 30px;
      margin-bottom: 6px;
      height: 60px;
    }
    #app .item .value,
    #app .skeleton .value {
      display: inline-block;
      min-width: 31px;
      min-height: 16px;
      font-weight: bold;
      color: rgb(64, 158, 255);
    }
  </style>
</html>

Here, the native html method is used to introduce and display, and other web frameworks are the same. Here, elements are used to separate. Of course, appoint can also be used to specify elements.

HTEMLElmenttype involved

CanvasLineCap

attributetyperemarks
buttstring
roundstring
squarestring
Last Updated:
Contributors: tommyrunner