1
1
<template >
2
- <div class =" container" @click.self =" closeBook()" >
2
+ <div ref = " container " class =" container flex-grow-1 " @click.self =" closeBook()" >
3
3
<div id =" book" class =" flip-book" @click.self =" closeBook()" >
4
4
<slot name =" table-of-contents" />
5
5
@@ -32,7 +32,7 @@ import { PageFlip } from "page-flip";
32
32
const { urls, edgeWidth, coverRatio, coverHeight } = defineProps <{
33
33
urls: string [];
34
34
edgeWidth? : number ;
35
- coverRatio? : number ;
35
+ coverRatio: number ;
36
36
coverHeight? : number ;
37
37
}>();
38
38
const emit = defineEmits <{ (e : " close-book" ): void }>();
@@ -41,6 +41,8 @@ const slots = defineSlots<{
41
41
" table-of-contents" (): unknown ;
42
42
}>();
43
43
44
+ const container = ref <HTMLElement >();
45
+
44
46
const book = defineModel <PageFlip | undefined >(" book" );
45
47
const opened = defineModel <boolean >(" opened" , { default: false });
46
48
const opening = defineModel <boolean >(" opening" , { default: false });
@@ -73,12 +75,11 @@ onMounted(() => {
73
75
watch (
74
76
isReadyToOpen ,
75
77
(newValue ) => {
76
- if (newValue && coverRatio && coverHeight ) {
77
- const bookElement: HTMLElement = document .getElementById (" book" )! ;
78
- const height = coverHeight || bookElement .clientHeight ;
79
- const width = height / coverRatio / 2 ;
80
- book .value = new PageFlip (bookElement , {
81
- width ,
78
+ if (newValue && coverRatio ) {
79
+ const height = coverHeight || container .value ! .clientHeight ;
80
+ debugger ;
81
+ book .value = new PageFlip (document .getElementById (" book" )! , {
82
+ width: height / coverRatio ,
82
83
height ,
83
84
84
85
maxShadowOpacity: 0.5 ,
0 commit comments