What is the reason for not removing an element using the elem.remove () method; ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What is the reason for not removing an element using the elem.remove () method; ?

The Old Game Lines code contains the doTryMoveBallToNewPosition_End function, which is responsible for deleting the old ball (what moved to the target) and creating a new one at the target point - yes, it can be done for another, but that is not the question. The question is why the remove () method does not remove SOMETHING an element after the fact in this function. For this reason, there is added a control deletion of the same element again - and this always works. My thoughts are only assumption that the animation is still complete sometimes at the time of removal. I tried to use endElement for a slave animate tag - but that didn't help. So far the problem has been solved so far - but I don’t like the solution. Who can tell the reason for this behavior and how beautifully to solve it in such an implementation. https://code.sololearn.com/Wv209I1zo26q/?ref=app

22nd Jun 2019, 3:53 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
3 Answers
+ 5
Russian (original): Код Old Game Lines содержит функцию doTryMoveBallToNewPosition_End, отвечающую за удаление старого шарика (того, что перемещался к цели) и создание в целевой точке нового - да, может можно и подругому, но вопрос не в этом. Вопрос в том, почему метод remove() не удаляет ИНОГДА элемент по факту в этой функции. По этой причине там добавлено контрольное удаление этого же элемента еще раз - и это срабатывает всегда. У меня из мыслей только предположение о том, что анимация еще завершена иногда в момент выполнения удаления. Я пробовал применять endElement для подчинённого тега animate - но это не помогало. Пока проблема так как решена - но решение это мне не нравиться. Кто может подсказать причину такого поведения и как в такой реализации её красиво решить.
22nd Jun 2019, 3:55 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 2
&)
26th Jun 2019, 4:50 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 1
Hello
26th Jun 2019, 4:45 PM
Ayobami Akingbade
Ayobami Akingbade - avatar