From 2da05a4c71bfe9b136384d9e94fbfbef19f24550 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 27 Jun 2012 17:28:06 -0700 Subject: Performance fix for WebGL materials playing even when the dialog/file is no longer in view. Also pausing videos when switching documents. Signed-off-by: Nivesh Rajbhandari --- js/document/views/base.js | 3 +++ js/document/views/design.js | 29 +++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'js/document') diff --git a/js/document/views/base.js b/js/document/views/base.js index d13dce1a..89759195 100755 --- a/js/document/views/base.js +++ b/js/document/views/base.js @@ -40,6 +40,7 @@ exports.BaseDocumentView = Montage.create(Component, { if (this.iframe) { this.iframe.style.display = 'block'; this.iframe.style.opacity = 1; + this.toggleWebGlAnimation(true); } else { console.log('Error: View has no iframe to show!'); } @@ -54,6 +55,8 @@ exports.BaseDocumentView = Montage.create(Component, { if (this.iframe) { this.iframe.style.display = 'none'; this.iframe.style.opacity = 0; + this.pauseVideos(); + this.toggleWebGlAnimation(false); } else { console.log('Error: View has no iframe to hide!'); } diff --git a/js/document/views/design.js b/js/document/views/design.js index 6a60e1f9..5c7ba4fc 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -497,9 +497,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { // pauseVideos:{ value:function(){ - var i, videos = this.document.getElementsByTagName("video"); - for(i = 0; i < videos.length; i++){ - if(!videos[i].paused) videos[i].pause(); + if(this.document) { + var i, videos = this.document.getElementsByTagName("video"); + for(i = 0; i < videos.length; i++){ + if(!videos[i].paused) videos[i].pause(); + } } } }, @@ -523,9 +525,28 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { videos[i].src = ""; } } - } + }, //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// + toggleWebGlAnimation: { + value: function(show) { + if(this.document) { + var glCanvases = this.document.querySelectorAll('[data-RDGE-id]'), + glShapeModel; + if(glCanvases) { + for(var i = 0, len = glCanvases.length; i