Skip to content
Snippets Groups Projects
Commit 0e2fc545 authored by Yuriy Maksymets's avatar Yuriy Maksymets
Browse files

Not drawing the last point if not needed

parent 1dee92bf
No related branches found
No related tags found
2 merge requests!57Erasure intervals,!48Intuitive erasing
......@@ -172,9 +172,31 @@ function pointWasErased(eraseIntervals) {
)
}
function needToDrawLastPoint(points, pathID) {
if (points.length < 2) return true
const penultimatePointIndex = points.length - 2
const penPointEraseIntervals = getEraseIntervals(
pathID,
penultimatePointIndex,
)
if (
penPointEraseIntervals &&
penPointEraseIntervals.length &&
penPointEraseIntervals.some(
(interval) => interval[1] >= 1 - POINT_ERASE_LIMIT,
)
) {
return false
}
return true
}
function generatePointsForPathElem(pathElem, pathID, dataPoints) {
const points = dataPoints
document.getElementById("console").innerText = JSON.stringify(
TEST_ERASE_INTERVAL,
)
const appendToWholePath = (subPath) => {
if (!(subPath && subPath.length)) return
const subpathElem = generateSvgForSubpath(subPath)
......@@ -225,7 +247,9 @@ function generatePointsForPathElem(pathElem, pathID, dataPoints) {
}
}
appendToWholePath(subPath)
if (needToDrawLastPoint(points, pathID)) {
appendToWholePath(subPath)
}
}
const addOrUpdatePathElem = (pathElems, id, points) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment