2016-04-14 11 views

答えて

0

プレゼンテーションを開始する前に、DOMツリーのコピー(1)を作成してから、必要に応じて復元することができます(2)。

// (1) create DOM copy 
window.saved = document.body.cloneNode(true); 

Reveal.initialize({ 
    // initialisation parameters 
}); 

// (2) restore DOM to previous state 
document.body.parentNode.replaceChild(window.saved, document.body) 

プレゼンテーションを停止していてエラーが発生していません。唯一の問題は、プレゼンテーションをもう一度開始するために余分なことをする必要があることです。

4

Reveal.jsは、プレゼンテーションをプログラムによって終了させるメソッドを実装していませんでした。 Here is the list of methods available

Reveal.jsのインスタンスを破棄したい場合は、Reveal.jsチームが実装していない限り不可能です。 Revealイベントが初期化されたDOM要素を削除することができます。

Reveal.jsプレゼンテーションのすべてまたはすべてのインスタンスを破棄できるコードを次に示します。

Element.prototype.remove = function() { 
    this.parentElement.removeChild(this); 
} 
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() { 
    for(var i = this.length - 1; i >= 0; i--) { 
     if(this[i] && this[i].parentElement) { 
      this[i].parentElement.removeChild(this[i]); 
     } 
    } 
} 

document.querySelectorAll('.reveal').remove(); 

//To remove all containers created by Math Plugin  
var mathPluginContainers = document.querySelectorAll("[id^='MathJax']"); 
mathPluginContainers = Array.prototype.slice.call(mathPluginContainers); 
var mathPluginParents = mathPluginContainers.map(function(container) { 
    return container.parentElement; 
}); 

mathPluginParents.forEach(function (container, index) { 
    if (container.tagName === 'DIV') { 
     container.remove(); 
    } else { 
     container.removeChild(mathPluginContainers[index]); 
    } 
}); 
関連する問題