mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
nav/template stuff
This commit is contained in:
@ -1,18 +1,41 @@
|
||||
(function(window, document, framework) {
|
||||
|
||||
|
||||
function transitionBegin(e) {
|
||||
function initTransition(e) {
|
||||
var data = e.detail.data;
|
||||
displayTransition(data);
|
||||
}
|
||||
|
||||
var activePageElement = document.getElementById(framework.activePageId);
|
||||
if(activePageElement) {
|
||||
// No animation. Nothing fancy here, just display none to block
|
||||
function displayTransition(data) {
|
||||
// build a new main element to hold the new data
|
||||
var newMainElement = document.createElement("main");
|
||||
newMainElement.innerHTML = data.main;
|
||||
|
||||
activePageElement.parentNode.removeChild(activePageElement);
|
||||
}
|
||||
var oldMainElement = document.querySelector("main");
|
||||
oldMainElement.className += " hide remove-element";
|
||||
|
||||
insertPageIntoDom(newMainElement, oldMainElement, data);
|
||||
|
||||
history.pushState({}, data.title, data.url);
|
||||
|
||||
framework.trigger("pageview");
|
||||
framework.trigger("pageremove");
|
||||
}
|
||||
|
||||
// insert the new main element before the old main element
|
||||
function insertPageIntoDom(newMainElement, oldMainElement, data) {
|
||||
oldMainElement.parentNode.insertBefore(newMainElement, oldMainElement);
|
||||
|
||||
// inform the framework that a new page has been added to the DOM
|
||||
framework.trigger("pagecreate", {
|
||||
id: data.id,
|
||||
url: data.url,
|
||||
title: data.title
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
framework.on("pagetransition", transitionBegin);
|
||||
framework.on("pageloaded", initTransition);
|
||||
|
||||
|
||||
})(this, document, FM = this.FM || {});
|
||||
Reference in New Issue
Block a user