mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Fix up some problems when the animation duration is zero
We want to be able to suppress animations by making the duration zero
This commit is contained in:
parent
6333749d68
commit
ee33cbbc2e
@ -42,8 +42,7 @@ Modal.prototype.display = function(title,options) {
|
||||
modalFooter = document.createElement("div"),
|
||||
modalFooterHelp = document.createElement("span"),
|
||||
modalFooterButtons = document.createElement("span"),
|
||||
tiddler = this.wiki.getTiddler(title),
|
||||
d = duration + "ms";
|
||||
tiddler = this.wiki.getTiddler(title);
|
||||
// Don't do anything if the tiddler doesn't exist
|
||||
if(!tiddler) {
|
||||
return;
|
||||
@ -130,12 +129,12 @@ Modal.prototype.display = function(title,options) {
|
||||
{transform: "translateY(" + window.innerHeight + "px)"}
|
||||
]);
|
||||
// Set up an event for the transition end
|
||||
modalWrapper.addEventListener($tw.utils.convertEventName("transitionEnd"),function(event) {
|
||||
window.setTimeout(function() {
|
||||
if(wrapper.parentNode) {
|
||||
// Remove the modal message from the DOM
|
||||
document.body.removeChild(wrapper);
|
||||
}
|
||||
},false);
|
||||
},duration);
|
||||
// Don't let anyone else handle the tw-close-tiddler message
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
@ -152,7 +151,7 @@ Modal.prototype.display = function(title,options) {
|
||||
document.body.appendChild(wrapper);
|
||||
// Set up animation for the styles
|
||||
$tw.utils.setStyle(modalBackdrop,[
|
||||
{transition: "opacity " + d + " ease-out"}
|
||||
{transition: "opacity " + duration + "ms ease-out"}
|
||||
]);
|
||||
$tw.utils.setStyle(modalWrapper,[
|
||||
{transition: $tw.utils.roundTripPropertyName("transform") + " " + duration + "ms ease-in-out"}
|
||||
|
@ -27,7 +27,7 @@ Notifier.prototype.display = function(title,options) {
|
||||
// Create the wrapper divs
|
||||
var notification = document.createElement("div"),
|
||||
tiddler = this.wiki.getTiddler(title),
|
||||
d = $tw.utils.getAnimationDuration() + "ms";
|
||||
duration = $tw.utils.getAnimationDuration();
|
||||
// Don't do anything if the tiddler doesn't exist
|
||||
if(!tiddler) {
|
||||
return;
|
||||
@ -47,7 +47,7 @@ Notifier.prototype.display = function(title,options) {
|
||||
{opacity: "0"},
|
||||
{transformOrigin: "0% 0%"},
|
||||
{transform: "translateY(" + (-window.innerHeight) + "px)"},
|
||||
{transition: "opacity " + d + " ease-out, " + $tw.utils.roundTripPropertyName("transform") + " " + d + " ease-in-out"}
|
||||
{transition: "opacity " + duration + "ms ease-out, " + $tw.utils.roundTripPropertyName("transform") + " " + duration + "ms ease-in-out"}
|
||||
]);
|
||||
// Add the notification to the DOM
|
||||
document.body.appendChild(notification);
|
||||
|
@ -54,7 +54,7 @@ PageScroller.prototype.handleEvent = function(event) {
|
||||
Handle a scroll event hitting the page document
|
||||
*/
|
||||
PageScroller.prototype.scrollIntoView = function(element) {
|
||||
var duration = $tw.utils.getAnimationDuration()
|
||||
var duration = $tw.utils.getAnimationDuration();
|
||||
// Get the offset bounds of the element
|
||||
var bounds = {
|
||||
left: element.offsetLeft,
|
||||
@ -95,7 +95,12 @@ PageScroller.prototype.scrollIntoView = function(element) {
|
||||
var self = this,
|
||||
drawFrame;
|
||||
drawFrame = function () {
|
||||
var t = ((new Date()) - self.startTime) / duration;
|
||||
var t;
|
||||
if(duration <= 0) {
|
||||
t = 1;
|
||||
} else {
|
||||
t = ((new Date()) - self.startTime) / duration;
|
||||
}
|
||||
if(t >= 1) {
|
||||
self.cancelScroll();
|
||||
t = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user