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