mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(tabs): add animationEnabled property (#8704)
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.nativescript.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
// See this thread for more information https://stackoverflow.com/questions/9650265
|
||||
public class TabViewPager extends ViewPager {
|
||||
private boolean swipePageEnabled = true;
|
||||
private boolean animationEnabled = true;
|
||||
|
||||
public TabViewPager(Context context) {
|
||||
super(context);
|
||||
@@ -26,6 +23,10 @@ public class TabViewPager extends ViewPager {
|
||||
this.swipePageEnabled = enabled;
|
||||
}
|
||||
|
||||
public void setAnimationEnabled(boolean enabled) {
|
||||
this.animationEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
if (this.swipePageEnabled) {
|
||||
@@ -55,6 +56,7 @@ public class TabViewPager extends ViewPager {
|
||||
|
||||
@Override
|
||||
public void setCurrentItem(int item) {
|
||||
super.setCurrentItem(item, this.swipePageEnabled);
|
||||
boolean smoothScroll = this.animationEnabled && this.swipePageEnabled;
|
||||
super.setCurrentItem(item, smoothScroll);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user