Skip to content

Commit 3b8fc3b

Browse files
fix(splash-screen): change launchFadeOutDuration default to 0
1 parent 5d9c1fe commit 3b8fc3b

6 files changed

Lines changed: 12 additions & 5 deletions

File tree

splash-screen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ These config values are available:
9898
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
9999
| **`launchShowDuration`** | <code>number</code> | How long to show the launch splash screen when autoHide is enabled (in ms) | <code>500</code> | 1.0.0 |
100100
| **`launchAutoHide`** | <code>boolean</code> | Whether to auto hide the splash after launchShowDuration. | <code>true</code> | 1.0.0 |
101-
| **`launchFadeOutDuration`** | <code>number</code> | Duration for the fade out animation of the launch splash screen (in ms) Only available for Android, when using the Android 12 Splash Screen API. | <code>200</code> | 4.2.0 |
101+
| **`launchFadeOutDuration`** | <code>number</code> | Duration for the fade out animation of the launch splash screen (in ms) On Android, only available when using the Android 12 Splash Screen API. | <code>0</code> | 4.2.0 |
102102
| **`backgroundColor`** | <code>string</code> | Color of the background of the Splash Screen in hex format, #RRGGBB or #RRGGBBAA. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. | | 1.0.0 |
103103
| **`androidSplashResourceName`** | <code>string</code> | Name of the resource to be used as Splash Screen. Doesn't work on launch when using the Android 12 API. Only available on Android. | <code>splash</code> | 1.0.0 |
104104
| **`androidScaleType`** | <code>'CENTER' \| 'CENTER_CROP' \| 'CENTER_INSIDE' \| 'FIT_CENTER' \| 'FIT_END' \| 'FIT_START' \| 'FIT_XY' \| 'MATRIX'</code> | The [ImageView.ScaleType](https://developer.android.com/reference/android/widget/ImageView.ScaleType) used to scale the Splash Screen image. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. Only available on Android. | <code>FIT_XY</code> | 1.0.0 |

splash-screen/android/src/main/java/com/capacitorjs/plugins/splashscreen/SplashScreenConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SplashScreenConfig {
1111
private Integer launchShowDuration = 500;
1212
private boolean launchAutoHide = true;
1313
private Integer launchFadeInDuration = 0;
14-
private Integer launchFadeOutDuration = 200;
14+
private Integer launchFadeOutDuration = 0;
1515
private String resourceName = "splash";
1616
private boolean immersive = false;
1717
private boolean fullScreen = false;

splash-screen/ios/Sources/SplashScreenPlugin/SplashScreen.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ import Capacitor
99
var config: SplashScreenConfig = SplashScreenConfig()
1010
var hideTask: Any?
1111
var isVisible: Bool = false
12+
var isLaunchSplash: Bool = false
1213

1314
init(parentView: UIView, config: SplashScreenConfig) {
1415
self.parentView = parentView
1516
self.config = config
1617
}
1718

1819
public func showOnLaunch() {
20+
isLaunchSplash = true
1921
buildViews()
2022
if self.config.launchShowDuration == 0 {
2123
return
2224
}
2325
var settings = SplashScreenSettings()
2426
settings.showDuration = config.launchShowDuration
2527
settings.fadeInDuration = config.launchFadeInDuration
28+
settings.fadeOutDuration = config.launchFadeOutDuration
2629
settings.autoHide = config.launchAutoHide
2730
showSplash(settings: settings, completion: {}, isLaunchSplash: true)
2831
}
@@ -32,7 +35,9 @@ import Capacitor
3235
}
3336

3437
public func hide(settings: SplashScreenSettings) {
35-
hideSplash(fadeOutDuration: settings.fadeOutDuration, isLaunchSplash: false)
38+
let fadeOutDuration = self.isLaunchSplash ? config.launchFadeOutDuration : settings.fadeOutDuration
39+
self.isLaunchSplash = false
40+
hideSplash(fadeOutDuration: fadeOutDuration, isLaunchSplash: false)
3641
}
3742

3843
private func showSplash(settings: SplashScreenSettings, completion: @escaping () -> Void, isLaunchSplash: Bool) {

splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenConfig.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ public struct SplashScreenConfig {
88
var launchShowDuration = 500
99
var launchAutoHide = true
1010
let launchFadeInDuration = 0
11+
var launchFadeOutDuration = 0
1112
}

splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenPlugin.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class SplashScreenPlugin: CAPPlugin, CAPBridgedPlugin {
8282

8383
config.launchShowDuration = getConfig().getInt("launchShowDuration", config.launchShowDuration)
8484
config.launchAutoHide = getConfig().getBoolean("launchAutoHide", config.launchAutoHide)
85+
config.launchFadeOutDuration = getConfig().getInt("launchFadeOutDuration", config.launchFadeOutDuration)
8586
return config
8687
}
8788

splash-screen/src/definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ declare module '@capacitor/cli' {
2727
/**
2828
* Duration for the fade out animation of the launch splash screen (in ms)
2929
*
30-
* Only available for Android, when using the Android 12 Splash Screen API.
30+
* On Android, only available when using the Android 12 Splash Screen API.
3131
*
3232
* @since 4.2.0
33-
* @default 200
33+
* @default 0
3434
* @example 3000
3535
*/
3636
launchFadeOutDuration?: number;

0 commit comments

Comments
 (0)