You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
943 B
33 lines
943 B
import ImageViewer from './src/ImageViewer.vue'
|
|
import { isClient } from '@/utils/is'
|
|
import { createVNode, render, VNode } from 'vue'
|
|
import { ImageViewerProps } from './src/types'
|
|
|
|
let instance: Nullable<VNode> = null
|
|
|
|
export function createImageViewer(options: ImageViewerProps) {
|
|
if (!isClient) return
|
|
const {
|
|
urlList,
|
|
initialIndex = 0,
|
|
infinite = true,
|
|
hideOnClickModal = false,
|
|
appendToBody = false,
|
|
zIndex = 2000,
|
|
show = true
|
|
} = options
|
|
|
|
const propsData: Partial<ImageViewerProps> = {}
|
|
const container = document.createElement('div')
|
|
propsData.urlList = urlList
|
|
propsData.initialIndex = initialIndex
|
|
propsData.infinite = infinite
|
|
propsData.hideOnClickModal = hideOnClickModal
|
|
propsData.appendToBody = appendToBody
|
|
propsData.zIndex = zIndex
|
|
propsData.show = show
|
|
|
|
document.body.appendChild(container)
|
|
instance = createVNode(ImageViewer, propsData)
|
|
render(instance, container)
|
|
}
|
|
|