mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Tabs animation and selected index fixes (#8377)
* fix(tabs): animation freeze when chaning tabs * fix(tabs): poper item selecting programically
This commit is contained in:
@@ -474,7 +474,7 @@ export abstract class ViewBase extends Observable {
|
||||
* When returning true the callLoaded method will be run in setTimeout
|
||||
* Method is intended to be overridden by inheritors and used as "protected"
|
||||
*/
|
||||
_shouldDelayLoad(): boolean;
|
||||
_shouldDelayLayout(): boolean;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -561,12 +561,24 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
}
|
||||
}
|
||||
|
||||
private performLayout(currentRun = 0) {
|
||||
// if there's an animation in progress we need to delay the layout
|
||||
// we've added a guard of 5000 milliseconds execution
|
||||
// to make sure that the layout will happen even if the animation haven't finished in 5 seconds
|
||||
if (this._shouldDelayLayout() && currentRun < 100) {
|
||||
setTimeout(() => this.performLayout(currentRun), currentRun);
|
||||
currentRun++;
|
||||
} else {
|
||||
this.parent.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@profile
|
||||
public requestLayout(): void {
|
||||
// Default implementation for non View instances (like TabViewItem).
|
||||
const parent = this.parent;
|
||||
if (parent) {
|
||||
parent.requestLayout();
|
||||
this.performLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,15 +627,11 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
|
||||
public loadView(view: ViewBase): void {
|
||||
if (view && !view.isLoaded) {
|
||||
if (this._shouldDelayLoad()) {
|
||||
setTimeout(() => view.callLoaded());
|
||||
} else {
|
||||
view.callLoaded();
|
||||
}
|
||||
view.callLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
public _shouldDelayLoad(): boolean {
|
||||
public _shouldDelayLayout(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user