mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 14:23:53 +00:00
Update animations to use a timer instead the transitionEnd event
Thr trouble is that the transitionEnd event doesn't fire under some circumstances (eg if the animated element is hidden). So, it's more reliable to use a timer instead
This commit is contained in:
parent
b51fb9cfa9
commit
594f4ba204
@ -21,8 +21,7 @@ function slideOpen(domNode,options) {
|
|||||||
currPaddingTop = parseInt(computedStyle.paddingTop,10),
|
currPaddingTop = parseInt(computedStyle.paddingTop,10),
|
||||||
currHeight = domNode.offsetHeight;
|
currHeight = domNode.offsetHeight;
|
||||||
// Reset the margin once the transition is over
|
// Reset the margin once the transition is over
|
||||||
var transitionEventName = $tw.utils.convertEventName("transitionEnd");
|
setTimeout(function() {
|
||||||
domNode.addEventListener(transitionEventName,function handler(event) {
|
|
||||||
$tw.utils.setStyle(domNode,[
|
$tw.utils.setStyle(domNode,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
{marginBottom: ""},
|
{marginBottom: ""},
|
||||||
@ -32,11 +31,10 @@ function slideOpen(domNode,options) {
|
|||||||
{height: "auto"},
|
{height: "auto"},
|
||||||
{opacity: ""}
|
{opacity: ""}
|
||||||
]);
|
]);
|
||||||
domNode.removeEventListener(transitionEventName,handler,false);
|
|
||||||
if(options.callback) {
|
if(options.callback) {
|
||||||
options.callback();
|
options.callback();
|
||||||
}
|
}
|
||||||
},false);
|
},$tw.config.preferences.animationDuration);
|
||||||
// Set up the initial position of the element
|
// Set up the initial position of the element
|
||||||
$tw.utils.setStyle(domNode,[
|
$tw.utils.setStyle(domNode,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
@ -68,8 +66,7 @@ function slideOpen(domNode,options) {
|
|||||||
function slideClosed(domNode,options) {
|
function slideClosed(domNode,options) {
|
||||||
var currHeight = domNode.offsetHeight;
|
var currHeight = domNode.offsetHeight;
|
||||||
// Clear the properties we've set when the animation is over
|
// Clear the properties we've set when the animation is over
|
||||||
var transitionEventName = $tw.utils.convertEventName("transitionEnd");
|
setTimeout(function() {
|
||||||
domNode.addEventListener(transitionEventName,function handler(event) {
|
|
||||||
$tw.utils.setStyle(domNode,[
|
$tw.utils.setStyle(domNode,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
{marginBottom: ""},
|
{marginBottom: ""},
|
||||||
@ -79,11 +76,10 @@ function slideClosed(domNode,options) {
|
|||||||
{height: "auto"},
|
{height: "auto"},
|
||||||
{opacity: ""}
|
{opacity: ""}
|
||||||
]);
|
]);
|
||||||
domNode.removeEventListener(transitionEventName,handler,false);
|
|
||||||
if(options.callback) {
|
if(options.callback) {
|
||||||
options.callback();
|
options.callback();
|
||||||
}
|
}
|
||||||
},false);
|
},$tw.config.preferences.animationDuration);
|
||||||
// Set up the initial position of the element
|
// Set up the initial position of the element
|
||||||
$tw.utils.setStyle(domNode,[
|
$tw.utils.setStyle(domNode,[
|
||||||
{height: currHeight + "px"},
|
{height: currHeight + "px"},
|
||||||
|
@ -37,14 +37,12 @@ ClassicListView.prototype.insert = function(index) {
|
|||||||
currMarginTop = parseInt(window.getComputedStyle(targetElement).marginTop,10),
|
currMarginTop = parseInt(window.getComputedStyle(targetElement).marginTop,10),
|
||||||
currHeight = targetElement.offsetHeight + currMarginTop;
|
currHeight = targetElement.offsetHeight + currMarginTop;
|
||||||
// Reset the margin once the transition is over
|
// Reset the margin once the transition is over
|
||||||
var transitionEventName = $tw.utils.convertEventName("transitionEnd");
|
setTimeout(function() {
|
||||||
targetElement.addEventListener(transitionEventName,function handler(event) {
|
|
||||||
$tw.utils.setStyle(targetElement,[
|
$tw.utils.setStyle(targetElement,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
{marginBottom: ""}
|
{marginBottom: ""}
|
||||||
]);
|
]);
|
||||||
targetElement.removeEventListener(transitionEventName,handler,false);
|
},$tw.config.preferences.animationDuration);
|
||||||
},false);
|
|
||||||
// Set up the initial position of the element
|
// Set up the initial position of the element
|
||||||
$tw.utils.setStyle(targetElement,[
|
$tw.utils.setStyle(targetElement,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
@ -69,12 +67,12 @@ ClassicListView.prototype.remove = function(index) {
|
|||||||
currMarginBottom = parseInt(window.getComputedStyle(targetElement).marginBottom,10),
|
currMarginBottom = parseInt(window.getComputedStyle(targetElement).marginBottom,10),
|
||||||
currMarginTop = parseInt(window.getComputedStyle(targetElement).marginTop,10),
|
currMarginTop = parseInt(window.getComputedStyle(targetElement).marginTop,10),
|
||||||
currHeight = targetElement.offsetHeight + currMarginTop;
|
currHeight = targetElement.offsetHeight + currMarginTop;
|
||||||
// Attach an event handler for the end of the transition
|
// Remove the element at the end of the transition
|
||||||
targetElement.addEventListener($tw.utils.convertEventName("transitionEnd"),function(event) {
|
setTimeout(function() {
|
||||||
if(targetElement.parentNode) {
|
if(targetElement.parentNode) {
|
||||||
targetElement.parentNode.removeChild(targetElement);
|
targetElement.parentNode.removeChild(targetElement);
|
||||||
}
|
}
|
||||||
},false);
|
},$tw.config.preferences.animationDuration);
|
||||||
// Animate the closure
|
// Animate the closure
|
||||||
$tw.utils.setStyle(targetElement,[
|
$tw.utils.setStyle(targetElement,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
|
@ -20,14 +20,12 @@ PopListView.prototype.insert = function(index) {
|
|||||||
var listElementNode = this.listWidget.children[index],
|
var listElementNode = this.listWidget.children[index],
|
||||||
targetElement = listElementNode.domNode;
|
targetElement = listElementNode.domNode;
|
||||||
// Reset once the transition is over
|
// Reset once the transition is over
|
||||||
var transitionEventName = $tw.utils.convertEventName("transitionEnd");
|
setTimeout(function() {
|
||||||
targetElement.addEventListener(transitionEventName,function handler(event) {
|
|
||||||
$tw.utils.setStyle(targetElement,[
|
$tw.utils.setStyle(targetElement,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
{transform: "none"}
|
{transform: "none"}
|
||||||
]);
|
]);
|
||||||
targetElement.removeEventListener(transitionEventName,handler,false);
|
},$tw.config.preferences.animationDuration);
|
||||||
},false);
|
|
||||||
// Set up the initial position of the element
|
// Set up the initial position of the element
|
||||||
$tw.utils.setStyle(targetElement,[
|
$tw.utils.setStyle(targetElement,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
@ -47,14 +45,12 @@ PopListView.prototype.insert = function(index) {
|
|||||||
PopListView.prototype.remove = function(index) {
|
PopListView.prototype.remove = function(index) {
|
||||||
var listElementNode = this.listWidget.children[index],
|
var listElementNode = this.listWidget.children[index],
|
||||||
targetElement = listElementNode.domNode;
|
targetElement = listElementNode.domNode;
|
||||||
// Attach an event handler for the end of the transition
|
// Remove the element at the end of the transition
|
||||||
var transitionEventName = $tw.utils.convertEventName("transitionEnd");
|
setTimeout(function() {
|
||||||
targetElement.addEventListener(transitionEventName,function handler(event) {
|
|
||||||
if(targetElement.parentNode) {
|
if(targetElement.parentNode) {
|
||||||
targetElement.parentNode.removeChild(targetElement);
|
targetElement.parentNode.removeChild(targetElement);
|
||||||
}
|
}
|
||||||
targetElement.removeEventListener(transitionEventName,handler,false);
|
},$tw.config.preferences.animationDuration);
|
||||||
},false);
|
|
||||||
// Animate the closure
|
// Animate the closure
|
||||||
$tw.utils.setStyle(targetElement,[
|
$tw.utils.setStyle(targetElement,[
|
||||||
{transition: "none"},
|
{transition: "none"},
|
||||||
|
@ -421,6 +421,10 @@ a.tw-tiddlylink-external {
|
|||||||
color: #182955;
|
color: #182955;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title img {
|
||||||
|
height: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.tw-subtitle {
|
.tw-subtitle {
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
color: #c0c0c0;
|
color: #c0c0c0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user