// eslint-disable-next-line no-unused-vars
import { JqsvOption, JqsvDOM, JqsvData } from '../types'
import globalConfig from '../config'
import { toPx } from '../helper/util'
import $ from 'jquery'
import shake from '../extend/shake'
class Jqsv {
readonly _options: JqsvOption
readonly _el: JQuery
readonly _DOM: JqsvDOM
readonly _blockMeta: { width: number; height: number; imageCache: HTMLElement | null }
readonly _moveState: {
originX: number
isTouching: boolean
}
readonly _successAnimationChain: ((resolve: (value?: unknown) => void) => void)[]
_destory?: () => void
state: string
constructor(options: JqsvOption, el: HTMLElement) {
this._options = options
this._el = $(el)
this.state = 'loaded'
this._successAnimationChain = []
this._blockMeta = {
width: 0,
height: 0,
imageCache: null
}
this._moveState = {
originX: 0,
isTouching: false
}
this._DOM = {
componentWraper: $('
', { class: 'valid-wraper' }).css({
width: toPx(this._options.data.imgWidth, globalConfig.padding),
height: toPx(
this._options.data.imgHeight,
globalConfig.sliderContainerHeight,
globalConfig.actionBarHeight,
globalConfig.padding
)
}),
blockImage: $('
![]()
', {
src: this._options.data.small
}),
canvasContainer: $('
', {
class: 'canvas-container'
}),
canvas: $('