FSPagerView icon indicating copy to clipboard operation
FSPagerView copied to clipboard

How to increase height of left and right item in linear case ?

Open kimteApril opened this issue 5 years ago • 4 comments

kimteApril avatar Mar 04 '19 05:03 kimteApril

I need the same!, someone who can help? Thx!

martinregas avatar Jul 17 '19 03:07 martinregas

any help?

Gadolizm avatar Oct 10 '19 14:10 Gadolizm

Subclass FSPagerViewTransformer and override func applyTransform(to attributes: FSPagerViewLayoutAttributes) worked for me.

class NoVerticalScalePagerViewTransformer: FSPagerViewTransformer {
    
    override func applyTransform(to attributes: FSPagerViewLayoutAttributes) {
        guard let pagerView = self.pagerView else {
            return
        }
        let position = attributes.position
        let scrollDirection = pagerView.scrollDirection
        let itemSpacing = (scrollDirection == .horizontal ? attributes.bounds.width : attributes.bounds.height) + self.proposedInteritemSpacing()
        if self.type == .linear {
            guard scrollDirection == .horizontal else {
                // This type doesn't support vertical mode
                return
            }
            let scale = max(1 - (1-self.minimumScale) * abs(position), self.minimumScale)
            // let transform = CGAffineTransform(scaleX: scale, y: scale)
            // **Modify here**
            let transform = CGAffineTransform(scaleX: scale, y: 1.0)
            attributes.transform = transform
            let alpha = (self.minimumAlpha + (1-abs(position))*(1-self.minimumAlpha))
            attributes.alpha = alpha
            let zIndex = (1-abs(position)) * 10
            attributes.zIndex = Int(zIndex)
        } else {
            super.applyTransform(to: attributes)
        }
    }
    
}

closure11 avatar Feb 26 '20 09:02 closure11

thanks @closure11 it works.

and use this, if you want to specifically change the height of the left and right items...

let scaleX = max(1 - (1-self.minimumScale) * abs(position), self.minimumScale)
let scaleY = max(1 - (1-0.90) * abs(position), 0.90)
let transform = CGAffineTransform(scaleX: scaleX, y: scaleY)

sseno avatar Feb 21 '23 17:02 sseno