mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
nav stuff
This commit is contained in:
@ -1,30 +1,41 @@
|
||||
(function(window, document, framework) {
|
||||
|
||||
function initTransition(e) {
|
||||
function initTransitions(e) {
|
||||
var data = e.detail.data;
|
||||
displayTransition(data);
|
||||
}
|
||||
|
||||
// No animation. Nothing fancy here, just display none to block
|
||||
function displayTransition(data) {
|
||||
// build a new main element to hold the new data
|
||||
// build a new main element to hold the new html
|
||||
var newMainElement = document.createElement("main");
|
||||
newMainElement.innerHTML = data.main;
|
||||
|
||||
// get the old main element, which will be the first one
|
||||
var oldMainElement = document.querySelector("main");
|
||||
|
||||
// decide how to do the page transition
|
||||
if(data.transition === "slide-from-left") {
|
||||
slideStart(newMainElement, oldMainElement, "left");
|
||||
} else {
|
||||
// No animation. Nothing fancy here
|
||||
noTransition(newMainElement, oldMainElement, data);
|
||||
}
|
||||
}
|
||||
|
||||
function noTransition(newMainElement, oldMainElement, data) {
|
||||
// entirely replace the old element, no transition
|
||||
oldMainElement.parentNode.replaceChild(newMainElement, oldMainElement);
|
||||
framework.trigger("pagecreate", {
|
||||
id: data.id,
|
||||
url: data.url,
|
||||
title: data.title
|
||||
});
|
||||
|
||||
history.pushState({}, data.title, data.url);
|
||||
|
||||
framework.trigger("pageview");
|
||||
}
|
||||
|
||||
framework.on("pageloaded", initTransition);
|
||||
function slideStart(newMainElement, oldMainElement, fromDirection) {
|
||||
// copy what the main element currently looks like into a document fragment
|
||||
// make all the changes to the document fragment, then replace the
|
||||
// old main with the two new ones. Both the old and new main will be
|
||||
// in the DOM, but their CSS classes will do the transitioning for us
|
||||
}
|
||||
|
||||
framework.on("pageloaded", initTransitions);
|
||||
|
||||
})(this, document, FM = this.FM || {});
|
||||
|
||||
Reference in New Issue
Block a user