MCPcopy
hub / github.com/ollm/OpenComic / disposeImages

Function disposeImages

scripts/reading.js:297–667  ·  view source on GitHub ↗
(data = false)

Source from the content-addressed store, hash-verified

295}
296
297function disposeImages(data = false)
298{
299 let _margin = readingMargin(data);
300
301 let margin = _margin.margin;
302 let marginHorizontal = _margin.left;
303 let marginVertical = _margin.top;
304 let marginHorizontalsHorizontal = readingHorizontalsMargin(data).left;
305
306 const forceSinglePage = (_config.readingForceSinglePage && !_config.readingWebtoon) ? true : false;
307
308 let contentRight = template._contentRight();
309 let rect = contentRight.firstElementChild.getBoundingClientRect();
310
311 let contentHeight = rect.height;
312 let contentWidth = rect.width;
313
314 if(readingViewIs('scroll'))
315 contentWidth = contentRight.querySelector('.reading-body').getBoundingClientRect().width;
316
317 //Width 0
318 let contentWidth0 = contentWidth - (marginHorizontal * 2);
319 let aspectRatio0 = contentWidth0 / (contentHeight - marginVertical * 2);
320
321 //Width horizontals 0
322 let contentWidthHorizontals0 = contentWidth - (marginHorizontalsHorizontal * 2);
323 let aspectRatioHorizontals0 = contentWidthHorizontals0 / (contentHeight - marginVertical * 2);
324
325 let _imagesDistribution = applyMangaReading(imagesDistribution);
326
327 let imageClip = readingImageClip();
328
329 let clipTop = imageClip.top / 100;
330 let clipBottom = imageClip.bottom / 100;
331 let clipVertical = clipTop + clipBottom;
332 let clipLeft = imageClip.left / 100;
333 let clipRight = imageClip.right / 100;
334 let clipHorizontal = clipLeft + clipRight;
335
336 let allImages = contentRight.querySelectorAll('.r-img');
337
338 let imageElements = {};
339
340 for(let i = 0, len = allImages.length; i < len; i++)
341 {
342 let image = allImages[i];
343
344 let key1 = +image.dataset.key1;
345 let key2 = +image.dataset.key2;
346
347 if(!imageElements[key1]) imageElements[key1] = {};
348 if(!imageElements[key1][key2]) imageElements[key1][key2] = [];
349
350 imageElements[key1][key2].push(image.firstElementChild);
351 }
352
353 let readingNotEnlargeMoreThanOriginalSize = _config.readingNotEnlargeMoreThanOriginalSize ? true : false;
354

Callers 5

resizedFunction · 0.85
changePagesViewFunction · 0.85
fastUpdateEbookPagesFunction · 0.85
generateEbookPagesFunction · 0.85
readFunction · 0.85

Calls 7

readingMarginFunction · 0.85
readingHorizontalsMarginFunction · 0.85
readingViewIsFunction · 0.85
applyMangaReadingFunction · 0.85
readingImageClipFunction · 0.85
calcAspectRatioFunction · 0.85
rotateImageFunction · 0.85

Tested by

no test coverage detected