Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an auto-destroy prop and destroy method #157

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/vue-pdf/src/components/VuePDF.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const props = withDefaults(defineProps<{
width?: number
height?: number
textLayer?: boolean
autoDestroy?: boolean
imageResourcesPath?: string
hideForms?: boolean
intent?: string
Expand All @@ -42,6 +43,7 @@ const props = withDefaults(defineProps<{
page: 1,
scale: 1,
intent: 'display',
autoDestroy: false
})

const emit = defineEmits<{
Expand Down Expand Up @@ -281,10 +283,15 @@ onMounted(() => {

onUnmounted(() => {
// Abort all network process and terminates the worker
props.pdf?.destroy()
if (props.autoDestroy)
props.pdf?.destroy()
})

// Exposed methods
// Exposed method
function destroy() {
props.pdf?.destroy()
}

function reload() {
renderPage(props.page)
}
Expand All @@ -296,6 +303,7 @@ function cancel() {
defineExpose({
reload,
cancel,
destroy
})
</script>

Expand Down