A SPA framework for the Mobile Web.
- Page life-cycle supported(refer Android、iOS);
- SEO friendly(Server side render needed);
- Pre-load;
- Lazy load;
- Multi-instance;
- Simple trigger are supported;
- LRU Histories maintain strategy;
- Single page reload(On demand);
- Easy way for Query string accessing;
- Enhancement that responsiveness for fast
- State-driven programing(similar Native App)
- Make your DOMs be Pretty and Clean
- Reduce the resources request
- Reduce costs(eg. CDN、Bandwidth...)
- Focus your things, no matter that routing、flow and MORE...
- Lightweight(15KB compressed, gzip enabled be better)
- Server:
Ngingx OR Apache
- Zepto OR jQuery lib are required
IMPORTANT:
- every DOMs of page, there are need to add the "page-ui" class at root element.
- If you do not explicitly call render method or configure the html property, And the Xfly will sends an XHR request based on the current path to get the view.
$Page.define('you.path.name', {
title: 'You first page',
html: '<div class="page-ui">' +
'<h1>Hello</h1>' +
'<a class="xfly-page__nav" data-if="hasMember" href="you/primary/page" data-else-href="you/second/page">Go to the Next page</a>' +
'</div>',
onCreateView: function() {
// Or here call render method to organization you DOM
// this.render( { url / html: '' } );
},
onRendering: function() {
},
onRendered: function() {
// Tip: Easy way to get the queries string
var args = this.getArgs();
console.log( 'The key value is ' + args[ 'key' ] );
},
onResume: function () {
console.log( this.id + ' be resumed.' );
},
onPause: function () {
console.log( this.id + ' be paused.' );
}
});
Forward(with Logic Expression):
<a class="xfly-page__nav" data-if="hasMember" href="you/primary/page" data-else-href="you/second/page">Go to the Next page</a>
OR
go( 'you.primary.page' );
Backward:
<a class="xfly-page__back" href="">Get back</a>
OR
back();
Be careful, the Browser Cache, GOOD LUCK FOR YOU.
See the https://c-ong.github.io OR the examples code dir.
title
String
Title of the pagehtml
String
Used as view of the pageurl
String
Used to load the view of the page via XHR requesttrigger
Object
Define a trigger
trigger: {
on: 'home',
state: 'show',
do: function() {
}
}
multitask
Boolean
Indicate whether the page is multi-instance, default isfalse
args
Object
Pre-define the Query strings of the PageonReload
Function
Called when the page reload action are triggered- ...
onCreate
Called when the instance of Page is createdonCreateView
Called when the view of Page will createonStart
Called after the view of Page is createdonAttach
Called when the view of Page is attached to thedocument.body
onResume
Called after the view of Page is attached and bevisible
onPause
Called when the User requesting the navigation forwardonStop
Called after the page ispaused
onDetach
Called after the page ispaused
and the View of page will detach from thedocument.body
onStop
Called after the view of page isdetached
onDestroyView
Controversial, not implemented yetonDestroy
Controversial, not implemented yet- ...
setTitle(String)
void
Update thedocument.title
getArgs()
Object
Accessing the Query strings of the Pagerender( { html: '' } / { url: '' } )
void
Request the rendering operationreload
void
To trigger reload the View of the Page- ...
onBeforePageChange(currently, upcoming)
Function
Called before the Page switchonAfterPageChange(older, currently)
Function
Called after the Page switchedonCurrentPageContentLoaded()
Function
Called when the view of Page is load- ...
go(id, args)
void
Request the navigation forward,args
is optional
go( 'you.page.id', { key: 'value' } );
back()
void
Request the navigation backward- ...
- If your are running without server-side render, you can provide a custom 404 page for general solution, just like this 404.html.
- Scroll restoration supported
- Simple logic express support for nav forward link
- Failure handle while fetch the view
- Desktop browser supported(like IE)
- State-full triggers supported
- Specific page extension name supported(eg. article.html、detail.php...)
- document.baseURI support(for Sub path)
- Root path supported(treat as default)
- For more features, you wishing, leave you idea
Click to get the base.fly.
Licensed under the MIT license.