package com.base.browserwhite.label;

import android.view.View;

import androidx.viewpager2.widget.ViewPager2;

import com.base.browserwhite.MyApplication;
import com.base.browserwhite.utils.Utils;

public class LabelPageTransformer implements ViewPager2.PageTransformer {
    private static final float MIN_SCALE = 0.8f;

    @Override
    public void transformPage(View page, float position) {
        if (position < -1) {
            page.setAlpha(0);
        } else if (position <= 0) {
            page.setAlpha(1);
            float n = -page.getHeight() * position +(position*Utils.INSTANCE.dpToPx(MyApplication.context,100));
            page.setTranslationY(n);
        } else if (position <= 1) {
            page.setAlpha(1 - position);
            float n = page.getHeight() * -position - (Utils.INSTANCE.dpToPx(MyApplication.context,100)*position);
            page.setTranslationY(n);
            // Keep the page at the same scale
        } else {
            page.setAlpha(0);
        }
    }
}
