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.
titleStringTitle of the pagehtmlStringUsed as view of the pageurlStringUsed to load the view of the page via XHR requesttriggerObjectDefine a trigger
trigger: {
on: 'home',
state: 'show',
do: function() {
}
}multitaskBooleanIndicate whether the page is multi-instance, default isfalseargsObjectPre-define the Query strings of the PageonReloadFunctionCalled when the page reload action are triggered- ...
onCreateCalled when the instance of Page is createdonCreateViewCalled when the view of Page will createonStartCalled after the view of Page is createdonAttachCalled when the view of Page is attached to thedocument.bodyonResumeCalled after the view of Page is attached and bevisibleonPauseCalled when the User requesting the navigation forwardonStopCalled after the page ispausedonDetachCalled after the page ispausedand the View of page will detach from thedocument.bodyonStopCalled after the view of page isdetachedonDestroyViewControversial, not implemented yetonDestroyControversial, not implemented yet- ...
setTitle(String)voidUpdate thedocument.titlegetArgs()ObjectAccessing the Query strings of the Pagerender( { html: '' } / { url: '' } )voidRequest the rendering operationreloadvoidTo trigger reload the View of the Page- ...
onBeforePageChange(currently, upcoming)FunctionCalled before the Page switchonAfterPageChange(older, currently)FunctionCalled after the Page switchedonCurrentPageContentLoaded()FunctionCalled when the view of Page is load- ...
go(id, args)voidRequest the navigation forward,argsis optional
go( 'you.page.id', { key: 'value' } );back()voidRequest 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.
