package com.mytatvarnsdk.myView.horizonViewPager;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.ViewPager;

public class ScaleInTransformer implements ViewPager.PageTransformer {

    private static final float MIN_SCALE = 0.6f;
    private static final float MIN_ALPHA = 0.5f;


    @Override
    public void transformPage(@NonNull View page, float position) {
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        if (position < 1) {
            float scaleX = 1 + MIN_SCALE * (position - 1);
            page.setScaleX(scaleX);
            page.setScaleY(scaleX);
        } else if (position == 1) {
            page.setScaleX(1);
            page.setScaleY(1);
        } else {
            float scaleX = 1 - MIN_SCALE * (position - 1);
            page.setScaleX(scaleX);
            page.setScaleY(scaleX);
        }
        page.setAlpha(1 - MIN_ALPHA * Math.abs(position - 1));
//        }

    }
}
