1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 17:10:29 +00:00

Niceties for JSHint

This commit is contained in:
Jeremy Ruston 2012-08-02 22:32:34 +01:00
parent 3ade3397fb
commit c11743088a
5 changed files with 16 additions and 10 deletions

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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;
};
})();

View File

@ -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)";