在div中移动最后一个孩子的Javascript问题

时间:2018-04-08 18:23:54

标签: javascript html animation

我有cards其中over time被添加progress bar progression clicks而用户moveCard buttonanimate添加move card {1}}或移走卡片。但是当我点击moving时它仍然是div时,它会将其放回原点并重新开始。

一旦它开始移动,有没有办法忘记delete?因为当我尝试moving时,它dissapears启动javascript file只是fiddle,这也是不正确的。

以下是我的var parentEl = document.getElementById("cards"); var elem = document.getElementById("myBar"); var width; var id; //Move card document.getElementById("moveCard").addEventListener("click", function () { myMove(); }); //Start the game document.getElementById("play").addEventListener("click", function() { move(); }); //Stop the game document.getElementById("stop").addEventListener("click", function() { stop(); }); function move() { width = 1; id = setInterval(frame, 5); function frame() { if (width >= 100) { elem.style.width = 1 + '%'; clearInterval(id); addCard(); move(); } else { width++; elem.style.width = width + '%'; } } } function myMove() { var elem = document.getElementById("cards").lastElementChild; var pos = 0; var id = setInterval(movie, 5); function movie() { if (pos == 350) { clearInterval(id); elem.remove(); } else { pos = pos + 5; elem.style.top = pos + 'px'; elem.style.left = pos + 'px'; } } } function addCard(){ var div = document.createElement("div"); div.style.position = "relative"; div.style.color = "green"; div.classList.add("card"); parentEl.appendChild(div); sortCards(); } function stop() { elem.style.width = 1 + '%'; clearInterval(id); } ,如果需要,我可以添加import pandas as pd import matplotlib.pyplot as plt l = [1,2,3,4,5,6] b = [6,5,4,3,2,1] for n in range(7): dflist = [] df = pd.DataFrame(l) dflist.append(df) df2 = pd.DataFrame(b) dflist.append(df2) df = pd.concat(dflist, axis = 1) ax = plt.subplot(4, 2, n + 1) df.plot(ax=ax)

<ng-container *ngFor="let outcome of market.Outcomes">
    <div class="market-cell-3" [class.selected-bet]="!outcome.removed">
        <span class="market-name">{{ outcome.name}}.</span>
    </div>
</ng-container>


removeItem(outcome) {
    outcome.removed = true;
}

这是小提琴:https://jsfiddle.net/bfnqmns2/

0 个答案:

没有答案