yanzhen-design-vue
Version:
84 lines (83 loc) • 2.06 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const utilsVue = require("@yanzhen-libs/utils-vue");
const imageViewerProps = utilsVue.buildProps({
fileList: {
type: Array,
default: () => []
},
isUploadViewer: Boolean
});
const imgCanPreviewFormats = [
"png",
"jpg",
"jpeg",
"gif",
"bmp",
"tif",
"apng",
"webp",
"ico"
];
const PICTURE_VIEWER_OPTIONS = {
title: false,
button: false,
minZoomRatio: 0.2,
maxZoomRatio: 5,
toolbar: {
zoomIn: true,
zoomOut: true,
oneToOne: true,
reset: true,
prev: true,
play: false,
custom: {
title: "play",
onClick: (event) => {
console.log("PlayPlayPlay", event);
}
},
next: true,
rotateLeft: true,
rotateRight: true,
flipHorizontal: true,
flipVertical: true
},
hide: (e) => {
console.log("hide-hide", e);
handleViewerHiddenRemoveEl();
}
};
const createCustomElementWithChildren = (className, children, onClick) => {
const elements = document.querySelectorAll(className);
if (!elements.length) {
const element = document.createElement("div");
element.className = className;
if (onClick) {
element.addEventListener("click", onClick);
}
children.forEach((child) => {
element.appendChild(child);
});
document.body.appendChild(element);
return element;
}
return null;
};
const handleViewerHiddenRemoveEl = () => {
const elementsToRemove = [
".image-viewer-top",
".image-prev",
".image-next",
".image-viewer-counts"
];
elementsToRemove.forEach((selector) => {
const elements = Array.from(document.querySelectorAll(selector));
elements.forEach((element) => element.remove());
});
};
exports.PICTURE_VIEWER_OPTIONS = PICTURE_VIEWER_OPTIONS;
exports.createCustomElementWithChildren = createCustomElementWithChildren;
exports.handleViewerHiddenRemoveEl = handleViewerHiddenRemoveEl;
exports.imageViewerProps = imageViewerProps;
exports.imgCanPreviewFormats = imgCanPreviewFormats;