1
1
2
- var images = { } , imagesData = { } , imagesPath = { } , imagesNum = 0 , contentNum = 0 , imagesNumLoad = 0 , currentIndex = 1 , imagesPosition = { } , imagesFullPosition = { } , foldersPosition = { } , indexNum = 0 , imagesDistribution = [ ] , currentPageXY = { x : 0 , y : 0 } ;
2
+ var images = { } , imagesData = { } , imagesDataClip = { } , imagesPath = { } , imagesNum = 0 , contentNum = 0 , imagesNumLoad = 0 , currentIndex = 1 , imagesPosition = { } , imagesFullPosition = { } , foldersPosition = { } , indexNum = 0 , imagesDistribution = [ ] , currentPageXY = { x : 0 , y : 0 } ;
3
3
4
4
//Calculates whether to add a blank image (If the reading is in double page and do not apply to the horizontals)
5
5
function blankPage ( index )
@@ -10,9 +10,9 @@ function blankPage(index)
10
10
{
11
11
for ( let i = index ; i < ( imagesNum + 1 ) ; i ++ )
12
12
{
13
- if ( typeof imagesData [ i ] !== 'undefined' )
13
+ if ( typeof imagesDataClip [ i ] !== 'undefined' )
14
14
{
15
- if ( imagesData [ i ] . aspectRatio > 1 )
15
+ if ( imagesDataClip [ i ] . aspectRatio > 1 )
16
16
{
17
17
return key % 2 ;
18
18
}
@@ -29,6 +29,35 @@ function blankPage(index)
29
29
}
30
30
}
31
31
32
+ function calculateImagesDataWithClip ( )
33
+ {
34
+ imagesDataClip = { } ;
35
+
36
+ let imageClip = _config . readingImageClip ;
37
+ let clipVertical = ( imageClip . top + imageClip . bottom ) / 100 ;
38
+ let clipHorizontal = ( imageClip . left + imageClip . right ) / 100 ;
39
+
40
+ if ( clipVertical === 0 && clipHorizontal === 0 )
41
+ return imagesDataClip = imagesData ;
42
+
43
+ for ( let i = 1 ; i < ( contentNum + 1 ) ; i ++ )
44
+ {
45
+ if ( typeof imagesData [ i ] !== 'undefined' )
46
+ {
47
+ let width = Math . round ( imagesData [ i ] . width * ( 1 - clipHorizontal ) ) ;
48
+ let height = Math . round ( imagesData [ i ] . height * ( 1 - clipVertical ) ) ;
49
+
50
+ imagesDataClip [ i ] = {
51
+ width : width ,
52
+ height : height ,
53
+ aspectRatio : ( width / height ) ,
54
+ } ;
55
+ }
56
+ }
57
+
58
+ return imagesDataClip ;
59
+ }
60
+
32
61
//Calculates the distribution of the images depending on the user's configuration
33
62
function calculateImagesDistribution ( )
34
63
{
@@ -39,14 +68,14 @@ function calculateImagesDistribution()
39
68
{
40
69
var data = [ ] ;
41
70
42
- if ( _config . readingBlankPage && ( ! _config . readingDoNotApplyToHorizontals || ( typeof imagesData [ 1 ] !== 'undefined' && imagesData [ 1 ] . aspectRatio <= 1 ) ) )
71
+ if ( _config . readingBlankPage && ( ! _config . readingDoNotApplyToHorizontals || ( typeof imagesDataClip [ 1 ] !== 'undefined' && imagesDataClip [ 1 ] . aspectRatio <= 1 ) ) )
43
72
data . push ( { index : false , folder : false , blank : true , width : 2 } ) ;
44
73
45
74
for ( let i = 1 ; i < ( contentNum + 1 ) ; i ++ )
46
75
{
47
- if ( typeof imagesData [ i ] !== 'undefined' )
76
+ if ( typeof imagesDataClip [ i ] !== 'undefined' )
48
77
{
49
- if ( _config . readingDoNotApplyToHorizontals && imagesData [ i ] . aspectRatio > 1 )
78
+ if ( _config . readingDoNotApplyToHorizontals && imagesDataClip [ i ] . aspectRatio > 1 )
50
79
{
51
80
if ( data . length > 0 )
52
81
{
@@ -57,7 +86,7 @@ function calculateImagesDistribution()
57
86
}
58
87
59
88
data . push ( { index : i , folder : false , blank : false , width : 1 } ) ;
60
- imagesData [ i ] . position = indexNum ;
89
+ imagesDataClip [ i ] . position = imagesData [ i ] . position = indexNum ;
61
90
imagesDistribution . push ( data ) ;
62
91
indexNum ++ ;
63
92
data = [ ] ;
@@ -68,7 +97,7 @@ function calculateImagesDistribution()
68
97
data . push ( { index : false , folder : false , blank : true , width : 2 } ) ;
69
98
70
99
data . push ( { index : i , folder : false , blank : false , width : 2 } ) ;
71
- imagesData [ i ] . position = indexNum ;
100
+ imagesDataClip [ i ] . position = imagesData [ i ] . position = indexNum ;
72
101
}
73
102
}
74
103
else
@@ -99,10 +128,10 @@ function calculateImagesDistribution()
99
128
{
100
129
for ( let i = 1 ; i < ( contentNum + 1 ) ; i ++ )
101
130
{
102
- if ( typeof imagesData [ i ] !== 'undefined' )
131
+ if ( typeof imagesDataClip [ i ] !== 'undefined' )
103
132
{
104
133
imagesDistribution . push ( [ { index : i , folder : false , blank : false , width : 1 } ] ) ;
105
- imagesData [ i ] . position = indexNum ;
134
+ imagesDataClip [ i ] . position = imagesData [ i ] . position = indexNum ;
106
135
indexNum ++ ;
107
136
}
108
137
else
@@ -170,6 +199,7 @@ function applyMangaReading(distribution)
170
199
// Add images distribution to html
171
200
function addHtmlImages ( )
172
201
{
202
+ calculateImagesDataWithClip ( ) ;
173
203
calculateImagesDistribution ( ) ;
174
204
175
205
var _imagesDistribution = applyMangaReading ( imagesDistribution ) ;
@@ -228,16 +258,16 @@ function calcAspectRatio(first, second)
228
258
if ( first . folder )
229
259
first . aspectRatio = 1 ;
230
260
else if ( first . blank )
231
- first . aspectRatio = second . folder ? 1 : imagesData [ second . index ] . aspectRatio ;
261
+ first . aspectRatio = second . folder ? 1 : imagesDataClip [ second . index ] . aspectRatio ;
232
262
else
233
- first . aspectRatio = imagesData [ first . index ] . aspectRatio ;
263
+ first . aspectRatio = imagesDataClip [ first . index ] . aspectRatio ;
234
264
}
235
265
else
236
266
{
237
267
if ( first . folder )
238
268
first . aspectRatio = 1 ;
239
269
else
240
- first . aspectRatio = imagesData [ first . index ] . aspectRatio ;
270
+ first . aspectRatio = imagesDataClip [ first . index ] . aspectRatio ;
241
271
}
242
272
243
273
return first ;
@@ -268,6 +298,15 @@ function disposeImages(data = false)
268
298
269
299
var _imagesDistribution = applyMangaReading ( imagesDistribution ) ;
270
300
301
+ let imageClip = _config . readingImageClip ;
302
+
303
+ let clipTop = imageClip . top / 100 ;
304
+ let clipBottom = imageClip . bottom / 100 ;
305
+ let clipVertical = clipTop + clipBottom ;
306
+ let clipLeft = imageClip . left / 100 ;
307
+ let clipRight = imageClip . right / 100 ;
308
+ let clipHorizontal = clipLeft + clipRight ;
309
+
271
310
for ( let key1 in _imagesDistribution )
272
311
{
273
312
var first = _imagesDistribution [ key1 ] [ 0 ] ;
@@ -307,22 +346,28 @@ function disposeImages(data = false)
307
346
if ( readingViewIs ( 'scroll' ) )
308
347
marginTop0 = marginTop1 = marginVertical ;
309
348
310
- template . contentRight ( '.image-position' + key1 + '-0 img, .image-position' + key1 + '-0 oc-img, .image-position'+ key1 + '-0 > div' ) . css ( {
349
+ template . contentRight ( '.image-position' + key1 + '-0 oc-img, .image-position' + key1 + '-0 > div' ) . css ( {
311
350
'height' : imageHeight0 + 'px' ,
312
351
'width' : imageWidth0 + 'px' ,
313
352
'margin-left' : marginLeft0 + 'px' ,
314
353
'margin-top' : marginTop0 + 'px' ,
315
354
'margin-bottom' : ( ( readingViewIs ( 'scroll' ) && ( ( + key1 ) + 1 ) == indexNum ) ? marginVertical : 0 ) + 'px' ,
316
355
'margin-right' : '0px' ,
356
+ } ) . find ( 'img' ) . css ( {
357
+ 'height' : imageHeight0 + 'px' ,
358
+ 'width' : imageWidth0 + 'px' ,
317
359
} ) ;
318
360
319
- template . contentRight ( '.image-position' + key1 + '-1 img, .image-position' + key1 + '-1 oc-img, .image-position'+ key1 + '-1 > div' ) . css ( {
361
+ template . contentRight ( '.image-position' + key1 + '-1 oc-img, .image-position' + key1 + '-1 > div' ) . css ( {
320
362
'height' : imageHeight1 + 'px' ,
321
363
'width' : imageWidth1 + 'px' ,
322
364
'margin-left' : marginLeft1 + 'px' ,
323
365
'margin-top' : marginTop1 + 'px' ,
324
366
'margin-bottom' : ( ( readingViewIs ( 'scroll' ) && ( ( + key1 ) + 1 ) == indexNum ) ? marginVertical : 0 ) + 'px' ,
325
367
'margin-right' : '0px' ,
368
+ } ) . find ( 'img' ) . css ( {
369
+ 'height' : imageHeight1 + 'px' ,
370
+ 'width' : imageWidth1 + 'px' ,
326
371
} ) ;
327
372
}
328
373
else
@@ -365,13 +410,21 @@ function disposeImages(data = false)
365
410
if ( readingViewIs ( 'scroll' ) )
366
411
marginTop = marginVertical ;
367
412
368
- template . contentRight ( '.image-position' + key1 + '-0 img, .image-position' + key1 + '-0 oc-img, .image-position' + key1 + '-0 > div' ) . css ( {
413
+ let imgHeight = ( clipVertical > 0 ? ( imageHeight / ( 1 - clipVertical ) ) : imageHeight ) ;
414
+ let imgWidth = ( clipHorizontal > 0 ? ( imageWidth / ( 1 - clipHorizontal ) ) : imageWidth ) ;
415
+
416
+ template . contentRight ( '.image-position' + key1 + '-0 oc-img, .image-position' + key1 + '-0 > div' ) . css ( {
369
417
'height' : imageHeight + 'px' ,
370
418
'width' : imageWidth + 'px' ,
371
419
'margin-left' : marginLeft + 'px' ,
372
420
'margin-top' : marginTop + 'px' ,
373
421
'margin-bottom' : ( ( readingViewIs ( 'scroll' ) && ( ( + key1 ) + 1 ) == indexNum ) ? marginVertical : 0 ) + 'px' ,
374
422
'margin-right' : '0px' ,
423
+ } ) . find ( 'img' ) . css ( {
424
+ 'height' : imgHeight + 'px' ,
425
+ 'width' : imgWidth + 'px' ,
426
+ 'margin-top' : - ( imgHeight * clipTop ) + 'px' ,
427
+ 'margin-left' : - ( imgWidth * clipLeft ) + 'px' ,
375
428
} ) ;
376
429
}
377
430
@@ -1863,6 +1916,24 @@ function changePagesView(mode, value, save)
1863
1916
1864
1917
if(save) updateReadingPagesConfig('readingHorizontalsMargin', {margin: _config.readingHorizontalsMargin.margin, top: value, bottom: value, left: _config.readingHorizontalsMargin.left, right: _config.readingHorizontalsMargin.right});
1865
1918
}*/
1919
+ else if ( mode == 16 ) // Clip horizontal images
1920
+ {
1921
+ updateReadingPagesConfig ( 'readingImageClip' , { top : _config . readingImageClip . top , bottom : _config . readingImageClip . bottom , left : value , right : value } ) ;
1922
+
1923
+ addHtmlImages ( ) ;
1924
+ disposeImages ( ) ;
1925
+ calculateView ( ) ;
1926
+ stayInLine ( ) ;
1927
+ }
1928
+ else if ( mode == 17 ) // Clip vertical images
1929
+ {
1930
+ updateReadingPagesConfig ( 'readingImageClip' , { top : value , bottom : value , left : _config . readingImageClip . left , right : _config . readingImageClip . right } ) ;
1931
+
1932
+ addHtmlImages ( ) ;
1933
+ disposeImages ( ) ;
1934
+ calculateView ( ) ;
1935
+ stayInLine ( ) ;
1936
+ }
1866
1937
}
1867
1938
1868
1939
//Change the bookmark icon
@@ -2502,7 +2573,7 @@ var touchTimeout, mouseOut = {lens: false, body: false}, touchStart = false, mag
2502
2573
//It starts with the reading of a comic, events, argar images, counting images ...
2503
2574
function read ( path , index = 1 , end = false )
2504
2575
{
2505
- images = { } , imagesData = { } , imagesPath = { } , imagesNum = 0 , contentNum = 0 , imagesNumLoad = 0 , currentIndex = index , foldersPosition = { } , currentScale = 1 , previousScrollTop = 0 , scalePrevData = { tranX : 0 , tranY : 0 , scale : 1 } ;
2576
+ images = { } , imagesData = { } , imagesDataClip = { } , imagesPath = { } , imagesNum = 0 , contentNum = 0 , imagesNumLoad = 0 , currentIndex = index , foldersPosition = { } , currentScale = 1 , previousScrollTop = 0 , scalePrevData = { tranX : 0 , tranY : 0 , scale : 1 } ;
2506
2577
2507
2578
loadReadingConfig ( currentReadingConfigKey ) ;
2508
2579
@@ -3177,6 +3248,7 @@ module.exports = {
3177
3248
contentNum : function ( ) { return contentNum } ,
3178
3249
imagesNumLoad : imagesNumLoad ,
3179
3250
imagesData : function ( ) { return imagesData } ,
3251
+ imagesDataClip : function ( ) { return imagesDataClip } ,
3180
3252
goToImage : goToImage ,
3181
3253
goToFolder : goToFolder ,
3182
3254
goToIndex : function ( v1 , v2 , v3 , v4 ) { readingDirection = true ; goToIndex ( v1 , v2 , v3 , v4 ) } ,
@@ -3193,6 +3265,7 @@ module.exports = {
3193
3265
changeMagnifyingGlass : changeMagnifyingGlass ,
3194
3266
changePagesView : changePagesView ,
3195
3267
magnifyingGlassControl : magnifyingGlassControl ,
3268
+ addHtmlImages : addHtmlImages ,
3196
3269
disposeImages : disposeImages ,
3197
3270
calculateView : calculateView ,
3198
3271
stayInLine : stayInLine ,
0 commit comments