MCPcopy Create free account
hub / github.com/Barrior/JParticles / constructor

Function constructor

src/common/base.ts:67–92  ·  view source on GitHub ↗
(
    defaultConfig: Options,
    selector: string | HTMLElement,
    options?: Partial<Options>
  )

Source from the content-addressed store, hash-verified

65 protected isRunningSupported = false
66
67 protected constructor(
68 defaultConfig: Options,
69 selector: string | HTMLElement,
70 options?: Partial<Options>
71 ) {
72 // 对于不支持运行特效的浏览器(如 IE8)将不支持创建特效
73 if (!isRuntimeSupported) return
74
75 this.container = isElement(selector)
76 ? (selector as HTMLElement)
77 : document.querySelector<HTMLElement>(selector as string)
78
79 this.isRunningSupported = !!this.container
80
81 if (this.container) {
82 this.options = merge({}, commonConfig, defaultConfig, options)
83 this.canvas = document.createElement('canvas')
84 this.ctx = this.canvas.getContext('2d')!
85
86 this.container.innerHTML = ''
87 this.container.appendChild(this.canvas)
88
89 // 缓存颜色获取函数,提高性能
90 this.getColor = this.makeColorMethod()
91 }
92 }
93
94 /**
95 * 引导程序

Callers

nothing calls this directly

Calls 2

isElementFunction · 0.90
mergeFunction · 0.90

Tested by

no test coverage detected