diff --git a/core/modules/macros/story/views/classic.js b/core/modules/macros/story/views/classic.js index 5ddce0a87..7390b0db2 100644 --- a/core/modules/macros/story/views/classic.js +++ b/core/modules/macros/story/views/classic.js @@ -39,7 +39,7 @@ ClassicScroller.prototype.remove = function(storyElementNode) { wrapperElement.style[$tw.browser.transform] = "translateX(0px)"; wrapperElement.style.opacity = "1.0"; wrapperElement.style.height = currHeight + "px"; - wrapperElement.offsetWidth; // Force layout + $tw.utils.forceLayout(wrapperElement); wrapperElement.style[$tw.browser.transform] = "translateX(" + window.innerWidth + "px)"; wrapperElement.style.opacity = "0.0"; wrapperElement.style.height = "0px"; diff --git a/core/modules/macros/story/views/sideways.js b/core/modules/macros/story/views/sideways.js index a1434b501..44c9d9ade 100644 --- a/core/modules/macros/story/views/sideways.js +++ b/core/modules/macros/story/views/sideways.js @@ -74,7 +74,7 @@ SidewaysView.prototype.remove = function(storyElementNode) { } },true); // Animate - wrapperElement.offsetWidth; // Force layout + $tw.utils.forceLayout(wrapperElement); wrapperElement.style[$tw.browser.transform] = "translateY(" + window.innerHeight + "px)"; wrapperElement.style.opacity = "0.0"; wrapperElement.style.width = "0px"; diff --git a/core/modules/macros/story/views/zoomin.js b/core/modules/macros/story/views/zoomin.js index ffe7cb00e..fd011a2f5 100644 --- a/core/modules/macros/story/views/zoomin.js +++ b/core/modules/macros/story/views/zoomin.js @@ -94,7 +94,7 @@ Zoomin.prototype.navigateForward = function(toStoryElement,fromStoryElement,hist prevCurrentTiddler = this.currentTiddler; this.currentTiddler = toStoryElement; // Force layout - this.storyNode.offsetWidth; + $tw.utils.forceLayout(this.storyNode); // Transform the target tiddler to its natural size toStoryElement.domNode.style[$tw.browser.transition] = "-" + $tw.browser.prefix.toLowerCase() + "-transform " + d + " ease-in-out, opacity " + d + " ease-out"; toStoryElement.domNode.style.opacity = "1.0"; @@ -102,7 +102,7 @@ Zoomin.prototype.navigateForward = function(toStoryElement,fromStoryElement,hist toStoryElement.domNode.style.zIndex = "500"; // Transform the previous tiddler out of the way and then hide it if(prevCurrentTiddler && prevCurrentTiddler !== toStoryElement) { - var scale = titleBounds.width / sourceBounds.width; + scale = titleBounds.width / sourceBounds.width; x = titleBounds.left - targetBounds.left - (sourceBounds.left - targetBounds.left) * scale; y = titleBounds.top - targetBounds.top - (sourceBounds.top - targetBounds.top) * scale; prevCurrentTiddler.domNode.style[$tw.browser.transition] = "-" + $tw.browser.prefix.toLowerCase() + "-transform " + d + " ease-in-out, opacity " + d + " ease-out"; @@ -154,8 +154,7 @@ Zoomin.prototype.remove = function(storyElement,storyElementIndex) { this.currentTiddler = toStoryElement; } // Animate them both - // Force layout - this.storyNode.offsetWidth; + $tw.utils.forceLayout(this.storyNode); // First, the tiddler we're closing storyElement.domNode.style[$tw.browser.transition] = "-" + $tw.browser.prefix.toLowerCase() + "-transform " + d + " ease-in-out, opacity " + d + " ease-out"; storyElement.domNode.style.opacity = "0.0"; diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index 35ac7b746..602906468 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -105,4 +105,11 @@ exports.getPassword = function(name) { return localStorage.getItem("tw5-password-" + name); }; +/* +Force layout of a dom node and its descendents +*/ +exports.forceLayout = function(element) { + var dummy = element.offsetWidth; +}; + })(); diff --git a/core/modules/utils/dom/modal.js b/core/modules/utils/dom/modal.js index 658f9b016..e4f9bbf5d 100644 --- a/core/modules/utils/dom/modal.js +++ b/core/modules/utils/dom/modal.js @@ -88,8 +88,8 @@ Modal.prototype.display = function(title) { // Add the close event handler wrapper.addEventListener("tw-close",function(event) { // Force layout and animate the modal message away - modalBackdrop.offsetWidth; - modalWrapper.offsetWidth; + $tw.utils.forceLayout(modalBackdrop); + $tw.utils.forceLayout(modalWrapper); modalBackdrop.style.opacity = 0; modalWrapper.style[$tw.browser.transform] = "translateY(" + window.innerHeight + "px)"; // Set up an event for the transition end @@ -113,8 +113,8 @@ Modal.prototype.display = function(title) { modalBackdrop.style[$tw.browser.transition] = "opacity " + d + " ease-out"; modalWrapper.style[$tw.browser.transition] = "-" + $tw.browser.prefix.toLowerCase() + "-transform " + d + " ease-in-out"; // Force layout - modalBackdrop.offsetWidth; - modalWrapper.offsetWidth; + $tw.utils.forceLayout(modalBackdrop); + $tw.utils.forceLayout(modalWrapper); // Set final animated styles modalBackdrop.style.opacity = 1; modalWrapper.style[$tw.browser.transform] = "translateY(0px)";