JWAutumn / ACarousel

A carousel view for SwiftUI | SwiftUI 旋转木马效果
MIT License
406 stars 81 forks source link

Fix ACarouselViewModel.itemWidth returning negative value #9

Closed krin-san closed 2 years ago

krin-san commented 3 years ago

Upon showing a View which contains ACarousel, 2 identical runtime warnings are produced in debug console. Both are pointing on this line. Adding a print statement (debugger in runtime was not that helpful) in ACarouselViewModel.itemWidth revealed the following:

0.0 - 30.0 * 2 -> -60.0
0.0 - 30.0 * 2 -> -60.0
2021-06-10 20:21:41.108133+0200 app[43860:8134542] [SwiftUI] Invalid frame dimension (negative or non-finite).
0.0 - 30.0 * 2 -> -60.0
2021-06-10 20:21:41.111586+0200 app[43860:8134542] [SwiftUI] Invalid frame dimension (negative or non-finite).
375.0 - 30.0 * 2 -> 315.0
375.0 - 30.0 * 2 -> 315.0
375.0 - 30.0 * 2 -> 315.0
375.0 - 30.0 * 2 -> 315.0
375.0 - 30.0 * 2 -> 315.0
375.0 - 30.0 * 2 -> 315.0