iCarousel icon indicating copy to clipboard operation
iCarousel copied to clipboard

Cycling custom type animation

Open maukur opened this issue 3 years ago • 0 comments

Does anyone know how I can cycle custom type?

Layout my view looks like this:

image

I use a custom type from here: Link


func carousel(_ carousel: iCarousel, itemTransformForOffset offset: CGFloat, baseTransform transform: CATransform3D) -> CATransform3D {
            let centerItemZoom: CGFloat = 1.329
            let centerItemSpacing: CGFloat = 1.41
        
            let spacing: CGFloat = 0.87
            let absClampedOffset = min(1.0, abs(offset))
            let clampedOffset = min(1.0, max(-1.0, offset))
            let scaleFactor = 1.0 + absClampedOffset * (1.0/centerItemZoom - 1.0)
            let offset = (scaleFactor * offset + scaleFactor * (centerItemSpacing - 1.0) * clampedOffset) * carousel.itemWidth * spacing
            var transform = CATransform3DTranslate(transform, offset, 0.0, -absClampedOffset)
            transform = CATransform3DScale(transform, scaleFactor, scaleFactor, 1.0)
            transform = CATransform3DTranslate(transform, 0, 11, 0)
            return transform
        }

maukur avatar Jul 05 '22 13:07 maukur