From 72f761f8df16a6603099eee50aa638116d7e36b6 Mon Sep 17 00:00:00 2001
From: mstefaniakap <46441806+mstefaniakap@users.noreply.github.com>
Date: Thu, 14 Mar 2019 19:14:39 +0100
Subject: [PATCH] Add skipInitialTransition prop (#29)
* Added skipInitialTransition prop
* Updated README.md to contain info about skipInitialTransition prop
* Added example called skip-initial-transition
---
README.md | 4 ++
examples/skip-initial-transition/.babelrc | 3 ++
examples/skip-initial-transition/package.json | 11 +++++
.../skip-initial-transition/pages/_app.js | 45 +++++++++++++++++++
.../pages/_document.js | 32 +++++++++++++
.../skip-initial-transition/pages/about.js | 20 +++++++++
.../skip-initial-transition/pages/index.js | 18 ++++++++
src/PageTransition.js | 8 ++--
8 files changed, 138 insertions(+), 3 deletions(-)
create mode 100644 examples/skip-initial-transition/.babelrc
create mode 100644 examples/skip-initial-transition/package.json
create mode 100644 examples/skip-initial-transition/pages/_app.js
create mode 100644 examples/skip-initial-transition/pages/_document.js
create mode 100644 examples/skip-initial-transition/pages/about.js
create mode 100644 examples/skip-initial-transition/pages/index.js
diff --git a/README.md b/README.md
index ed76b2c..f496a58 100644
--- a/README.md
+++ b/README.md
@@ -237,6 +237,10 @@ to gain a deeper sense of how this component works.
so that programmatic scrolling can be disabled while a page is transitioning
out. Defaults to false, since this potentially sketchy behavior should be
opt-in.
+* **`skipInitialTransition`**: Specifies if page transition will be omitted on
+ first mount. If you want to have transitions only between pages, not on
+ first page load, set `skipInitialTransition` to `true`. By default,
+ `skipInitialTransition` is set to `false`.
### Contributing
diff --git a/examples/skip-initial-transition/.babelrc b/examples/skip-initial-transition/.babelrc
new file mode 100644
index 0000000..1ff94f7
--- /dev/null
+++ b/examples/skip-initial-transition/.babelrc
@@ -0,0 +1,3 @@
+{
+ "presets": ["next/babel"]
+}
diff --git a/examples/skip-initial-transition/package.json b/examples/skip-initial-transition/package.json
new file mode 100644
index 0000000..180538f
--- /dev/null
+++ b/examples/skip-initial-transition/package.json
@@ -0,0 +1,11 @@
+{
+ "scripts": {
+ "dev": "next dev"
+ },
+ "dependencies": {
+ "next": "^8.0.3",
+ "next-page-transitions": "*",
+ "react": "^16.8.4",
+ "react-dom": "^16.8.4"
+ }
+}
diff --git a/examples/skip-initial-transition/pages/_app.js b/examples/skip-initial-transition/pages/_app.js
new file mode 100644
index 0000000..801bc86
--- /dev/null
+++ b/examples/skip-initial-transition/pages/_app.js
@@ -0,0 +1,45 @@
+import App, { Container } from 'next/app'
+import React from 'react'
+
+import { PageTransition } from 'next-page-transitions'
+
+export default class MyApp extends App {
+ static async getInitialProps({ Component, ctx }) {
+ let pageProps = {}
+
+ if (Component.getInitialProps) {
+ pageProps = await Component.getInitialProps(ctx)
+ }
+
+ return { pageProps }
+ }
+
+ render() {
+ const { Component, pageProps } = this.props
+ return (
+