data-scroll-animation
Advanced tools
Comparing version 1.0.3 to 1.0.4
# CHANGELOG | ||
## [1.0.4] - 2021-02-12 | ||
- fix continous render after removing element with base scroll parent | ||
- remove useless comments | ||
- update dependencies | ||
## [1.0.3] - 2021-02-11 | ||
@@ -4,0 +9,0 @@ - fix multiple render simultaneously |
@@ -314,4 +314,4 @@ /*! ***************************************************************************** | ||
requestAnimationFrame(function fn() { | ||
render(); | ||
if (!stop) { | ||
render(); | ||
requestAnimationFrame(fn); | ||
@@ -432,3 +432,9 @@ } | ||
} | ||
parse(element, firstScrollParent || baseScrollParent, subtree); | ||
if (firstScrollParent == null) { | ||
firstScrollParent = baseScrollParent; | ||
if (baseScrollParent.children.length === 0) { | ||
scrollParents.push(baseScrollParent); | ||
} | ||
} | ||
parse(element, firstScrollParent, subtree); | ||
if (scrollParents.length > 0) { | ||
@@ -462,4 +468,16 @@ startLoop(); | ||
Array.prototype.forEach.call(element.children, function (child) { | ||
remove(child); | ||
remove(child, renderFrame); | ||
}); | ||
if (scrollParent === baseScrollParent && baseScrollParent.children.length === 0) { | ||
var index_2 = -1; | ||
if (scrollParents.some(function (p, i) { | ||
if (p === baseScrollParent) { | ||
index_2 = i; | ||
return true; | ||
} | ||
return false; | ||
})) { | ||
scrollParents.splice(index_2, 1); | ||
} | ||
} | ||
if (scrollParents.length === 0) { | ||
@@ -466,0 +484,0 @@ endLoop(); |
@@ -320,4 +320,4 @@ (function (global, factory) { | ||
requestAnimationFrame(function fn() { | ||
render(); | ||
if (!stop) { | ||
render(); | ||
requestAnimationFrame(fn); | ||
@@ -438,3 +438,9 @@ } | ||
} | ||
parse(element, firstScrollParent || baseScrollParent, subtree); | ||
if (firstScrollParent == null) { | ||
firstScrollParent = baseScrollParent; | ||
if (baseScrollParent.children.length === 0) { | ||
scrollParents.push(baseScrollParent); | ||
} | ||
} | ||
parse(element, firstScrollParent, subtree); | ||
if (scrollParents.length > 0) { | ||
@@ -468,4 +474,16 @@ startLoop(); | ||
Array.prototype.forEach.call(element.children, function (child) { | ||
remove(child); | ||
remove(child, renderFrame); | ||
}); | ||
if (scrollParent === baseScrollParent && baseScrollParent.children.length === 0) { | ||
var index_2 = -1; | ||
if (scrollParents.some(function (p, i) { | ||
if (p === baseScrollParent) { | ||
index_2 = i; | ||
return true; | ||
} | ||
return false; | ||
})) { | ||
scrollParents.splice(index_2, 1); | ||
} | ||
} | ||
if (scrollParents.length === 0) { | ||
@@ -472,0 +490,0 @@ endLoop(); |
{ | ||
"name": "data-scroll-animation", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |
@@ -274,7 +274,3 @@ type FramePosition = number | "before" | "after"; | ||
let started: boolean = false; | ||
let interval: number = -1; | ||
function startLoop(): void { | ||
// if (interval !== -1) { | ||
// return; | ||
// } | ||
stop = false; | ||
@@ -286,4 +282,4 @@ if (started) { | ||
requestAnimationFrame(function fn(): void { | ||
render(); | ||
if (!stop) { | ||
render(); | ||
requestAnimationFrame(fn); | ||
@@ -294,10 +290,4 @@ } else { | ||
}); | ||
// interval = setInterval(render, 20); | ||
} | ||
function endLoop(): void { | ||
// if (interval === -1) { | ||
// return; | ||
// } | ||
// clearInterval(interval); | ||
// interval = -1; | ||
stop = true; | ||
@@ -399,3 +389,9 @@ } | ||
} | ||
parse(element, firstScrollParent || baseScrollParent, subtree); | ||
if (firstScrollParent == null) { | ||
firstScrollParent = baseScrollParent; | ||
if (baseScrollParent.children.length === 0) { | ||
scrollParents.push(baseScrollParent); | ||
} | ||
} | ||
parse(element, firstScrollParent, subtree); | ||
if (scrollParents.length > 0) { | ||
@@ -428,4 +424,16 @@ startLoop(); | ||
Array.prototype.forEach.call(element.children, child => { | ||
remove(child); | ||
remove(child, renderFrame); | ||
}); | ||
if (scrollParent === baseScrollParent && baseScrollParent.children.length === 0) { | ||
let index: number = -1; | ||
if (scrollParents.some((p, i) => { | ||
if (p === baseScrollParent) { | ||
index = i; | ||
return true; | ||
} | ||
return false; | ||
})) { | ||
scrollParents.splice(index, 1); | ||
} | ||
} | ||
if (scrollParents.length === 0) { | ||
@@ -432,0 +440,0 @@ endLoop(); |
@@ -319,4 +319,4 @@ (function (factory) { | ||
requestAnimationFrame(function fn() { | ||
render(); | ||
if (!stop) { | ||
render(); | ||
requestAnimationFrame(fn); | ||
@@ -329,2 +329,5 @@ } | ||
} | ||
function endLoop() { | ||
stop = true; | ||
} | ||
function parse(element, parent, subtree) { | ||
@@ -435,3 +438,9 @@ if (subtree === void 0) { subtree = true; } | ||
} | ||
parse(element, firstScrollParent || baseScrollParent, subtree); | ||
if (firstScrollParent == null) { | ||
firstScrollParent = baseScrollParent; | ||
if (baseScrollParent.children.length === 0) { | ||
scrollParents.push(baseScrollParent); | ||
} | ||
} | ||
parse(element, firstScrollParent, subtree); | ||
if (scrollParents.length > 0) { | ||
@@ -441,5 +450,54 @@ startLoop(); | ||
} | ||
function remove(element, renderFrame) { | ||
if (renderFrame === void 0) { renderFrame = null; } | ||
var scrollParent = element[SCROLL_PARENT]; | ||
var scrollObject = element[SCROLL_OBJECT]; | ||
if (scrollParent != null) { | ||
if (scrollParent.el === element) { | ||
var index_1 = -1; | ||
if (scrollParents.some(function (p, i) { | ||
index_1 = i; | ||
return p === scrollParent; | ||
})) { | ||
scrollParents.splice(index_1, 1); | ||
} | ||
} | ||
if (scrollObject != null) { | ||
scrollParent.remove(scrollObject); | ||
if (renderFrame != null) { | ||
scrollObject.render(renderFrame); | ||
} | ||
} | ||
delete element[SCROLL_PARENT]; | ||
delete element[SCROLL_OBJECT]; | ||
} | ||
Array.prototype.forEach.call(element.children, function (child) { | ||
remove(child, renderFrame); | ||
}); | ||
if (scrollParent === baseScrollParent && baseScrollParent.children.length === 0) { | ||
var index_2 = -1; | ||
if (scrollParents.some(function (p, i) { | ||
if (p === baseScrollParent) { | ||
index_2 = i; | ||
return true; | ||
} | ||
return false; | ||
})) { | ||
scrollParents.splice(index_2, 1); | ||
} | ||
} | ||
if (scrollParents.length === 0) { | ||
endLoop(); | ||
} | ||
} | ||
var scrollAnimation = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
add: add, | ||
remove: remove | ||
}); | ||
window.scrollAnimation = scrollAnimation; | ||
add(document.body); | ||
}))); |
import * as scrollAnimation from "../../src/index"; | ||
(window as any).scrollAnimation = scrollAnimation; | ||
// scrollAnimation.add(document.body.querySelector("#test") as HTMLElement); | ||
@@ -4,0 +5,0 @@ // setTimeout(() => { |
Sorry, the diff of this file is not supported yet
87934
16
1977