8000 feat: Add router transitions (#86) · rdlauer/nativescript-vue@381843e · GitHub
[go: up one dir, main page]

Skip to content

Commit 381843e

Browse files
authored
feat: Add router transitions (nativescript-vue#86)
* WIP: add router transitions * Add page transitions
1 parent 41fd3e5 commit 381843e

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"dependencies": {
4848
"he": "^1.1.1",
4949
"lint-staged": "^4.2.3",
50-
"vue": "^2.5.2"
50+
"vue": "^2.5.6"
5151
},
5252
"peerDependencies": {
5353
"tns-core-modules": "^3.0.0"

platform/nativescript/plugins/navigator-plugin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { isPage } from '../util/index'
22
import { Page } from 'ui/page'
33
import { topmost } from 'ui/frame'
44
import { start } from 'application'
5-
import application from 'application'
65
import { VUE_VM_REF } from '../runtime/index'
76
import { after } from '../util'
87

platform/nativescript/plugins/router-plugin.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ export function patchRouter(router, Vue) {
1717
router.isBackNavigation = false
1818
router.shouldNavigate = true
1919
router.pageStack = []
20+
router.pageTransition = null
21+
22+
router.setPageTransition = (transition, duration, curve) => {
23+
if (typeof transition === 'string') {
24+
return (router.pageTransition = {
25+
name: transition,
26+
duration,
27+
curve
28+
})
29+
}
30+
31+
router.pageTransition = transition
32+
}
2033

2134
router._beginBackNavigation = (shouldNavigate = true) => {
2235
if (router.isBackNavigation) {
@@ -68,7 +81,9 @@ export function patchRouter(router, Vue) {
6881
const component = router.getMatchedComponents()[0]
6982

7083
Vue.navigateTo(component, {
71-
context: { router }
84+
context: { router },
85+
transition: router.pageTransition
86+
// Todo: add transitionAndroid and transitionIOS
7287
}).then(page => {
7388
router.pageStack.push(page)
7489

samples/app/app-with-router-pages.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@ router.replace('/foo')
5555

5656
new Vue({
5757
router,
58-
template: `<router-page />`
58+
template: `<router-page />`,
59+
created() {
60+
// this.$setPageTransition('slide', 1000)
61+
}
5962
}).$start()

0 commit comments

Comments
 (0)
0