|
@@ -399,8 +399,7 @@ export function transition(el, stages) {
|
|
|
stages.end()
|
|
|
|
|
|
// Asign current transition to el in case we need to force it
|
|
|
- el.__x_transition_remaining =() => {
|
|
|
-
|
|
|
+ el.__x_transition_remaining = once(() => {
|
|
|
stages.hide()
|
|
|
|
|
|
// Adding an "isConnected" check, in case the callback
|
|
@@ -409,19 +408,11 @@ export function transition(el, stages) {
|
|
|
stages.cleanup()
|
|
|
}
|
|
|
|
|
|
- // Safe to remove transition from el since it is completed
|
|
|
- delete el.__x_transition_remaining
|
|
|
- if(el.__x_transition_timer){
|
|
|
- clearTimeout(el.__x_transition_timer)
|
|
|
- }
|
|
|
- }
|
|
|
+ // Safe to remove transition from el since it is completed
|
|
|
+ delete el.__x_transition_remaining
|
|
|
+ })
|
|
|
|
|
|
- el.__x_transition_timer = setTimeout(() => {
|
|
|
- // We only want to run remaining transitions in the end if they exists
|
|
|
- if (el.__x_transition_remaining) {
|
|
|
- el.__x_transition_remaining()
|
|
|
- }
|
|
|
- }, duration);
|
|
|
+ setTimeout(el.__x_transition_remaining, duration);
|
|
|
})
|
|
|
});
|
|
|
}
|
|
@@ -429,3 +420,16 @@ export function transition(el, stages) {
|
|
|
export function isNumeric(subject){
|
|
|
return ! isNaN(subject)
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Ensure a function is called only once.
|
|
|
+ */
|
|
|
+export function once(fn) {
|
|
|
+ let called = false
|
|
|
+ return function () {
|
|
|
+ if (!called) {
|
|
|
+ called = true
|
|
|
+ fn.apply(this, arguments)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|