Commit da6470a Sebastian Flick
committed
1 parent e0ee283 commit da6470a Copy full SHA for da6470a
File tree 3 files changed +16
-19
lines changed
routes/textzeugen/[[sigla]]/[[thirties]]/[[verse]]
3 files changed +16
-19
lines changed Original file line number Diff line number Diff line change 17
17
let viewer;
18
18
19
19
const generateViewer = (/** @type {Element} */ node , /** @type {Object} */ iiif ) => {
20
- const i = Number (node .id .split (' -' )[1 ]);
21
- if (! iiif) return ;
22
20
/** @type {ResizeObserver} */
23
21
let observer;
24
22
const createViewer = () => {
84
82
},
85
83
sequenceMode: false
86
84
});
87
- viewer .open (iiif);
88
85
observer = new ResizeObserver ((_entries ) => {
89
86
setTimeout (() => {
90
87
viewer .viewport .goHome (false );
91
88
}, 50 );
92
89
});
93
90
observer .observe (node);
91
+ if (! iiif) return ;
92
+ viewer .open (iiif);
94
93
};
95
94
if (! OpenSeadragon) {
96
95
import (' openseadragon' ).then ((r ) => {
106
105
* @param {Promise<Object>} iiif
107
106
*/
108
107
update (iiif ) {
108
+ if (! viewer) return ;
109
109
viewer .open (iiif);
110
110
},
111
111
destroy () {
Original file line number Diff line number Diff line change @@ -51,10 +51,13 @@ export async function load({ fetch, params }) {
51
51
entry . l . includes ( `${ thirties } .${ verse } ` )
52
52
) ;
53
53
54
- if ( selectedIndex > 0 ) returnObjects . push ( data [ witnes ] [ selectedIndex - 1 ] ?? { } ) ;
54
+ if ( selectedIndex > 0 ) {
55
+ returnObjects . push ( data [ witnes ] [ selectedIndex - 1 ] ?? { } ) ;
56
+ }
55
57
returnObjects . push ( data [ witnes ] [ selectedIndex ] ?? { } ) ;
56
- if ( selectedIndex <= data [ witnes ] . length - 1 )
58
+ if ( selectedIndex <= data [ witnes ] . length - 1 ) {
57
59
returnObjects . push ( data [ witnes ] [ selectedIndex + 1 ] ?? { } ) ;
60
+ }
58
61
} else {
59
62
returnObjects = [ data [ witnes ] [ 0 ] , data [ witnes ] [ 1 ] ] ;
60
63
}
Original file line number Diff line number Diff line change 65
65
setTarget (` ${ data .thirties } .${ data .verse } ` );
66
66
let localVerses = Array (data .content ? .length ).fill (` ${ data .thirties } .${ data .verse } ` );
67
67
let localPages = Array (data .content ? .length ).fill ([]);
68
+ let currentIiif = Array (data .content ? .length ).fill ({});
68
69
// fill the data from the load-function into the localPages array
69
70
data .content ? .forEach ((c , i ) => {
70
71
c .meta .then ((meta ) => {
71
72
localPages[i] = [... localPages[i], ... meta];
73
+ currentIiif[i] = meta[1 ]? .iiif ;
72
74
});
73
75
});
74
76
78
80
/** @type {string} */ sigla
79
81
) => {
80
82
const indexCurrent = localPages[i].findIndex ((p ) => p .page === e .detail .id );
81
-
83
+ localPages[i][indexCurrent]? .iiif .then ((iiif ) => {
84
+ currentIiif[i] = iiif;
85
+ });
82
86
const createObject = (/** @type {string} */ id ) => {
83
87
return {
84
88
page: id,
162
166
< / section>
163
167
{#if ! ($page .url .searchParams .get (' iiif' )? .split (' -' )[i] === ' true' )}
164
168
< section class = " min-h-[40vh]" >
165
- {#await localPages[i] then meta}
166
- {#if typeof meta === ' object' && typeof meta .tpData === ' object' }
167
- {#await meta .iiif }
168
- < p> Loading... < / p>
169
- {: then iiif}
170
- {#if typeof iiif === ' object' }
171
- < IIIFViewer {iiif} / >
172
- {/ if }
173
- {: catch error}
174
- < p style= " color: red" > {error .message }< / p>
175
- {/ await }
176
- {/ if }
177
- {/ await }
169
+ {#if typeof currentIiif[i] === ' object' && Object .keys (currentIiif[i]).length }
170
+ < IIIFViewer iiif= {currentIiif[i]} / >
171
+ {/ if }
178
172
< / section>
179
173
{/ if }
180
174
< / article>
You can’t perform that action at this time.
0 commit comments