Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Number Flip Counter #1

Open
56000 opened this issue Nov 16, 2021 · 2 comments
Open

Auto Number Flip Counter #1

56000 opened this issue Nov 16, 2021 · 2 comments

Comments

@56000
Copy link

56000 commented Nov 16, 2021

How can I flip card from 0-9, stop on certain number with Javascript?(image)

<html>
    <head>
        <link rel="stylesheet" href="flip-clock.css">
    </head>
    <body>
        <div id="flip-clock">
            <div class="flip-clock-container">
                <div class="flip-clock flip-clock-d">
                    <div class="digit digit-R" data-digit-before="R" data-digit-after="R">
                        <div class="card">
                            <div class="card-face card-face-front">R</div>
                            <div class="card-face card-face-back">R</div>
                        </div>
                    </div>
                    <div class="digit digit-M" data-digit-before="M" data-digit-after="M">
                        <div class="card">
                            <div class="card-face card-face-front">M</div>
                            <div class="card-face card-face-back">M</div>
                        </div>
                    </div>
                    <div class="digit digit-0">
                        <div class="card">
                            <div class="card-face card-face-front"></div>
                            <div class="card-face card-face-back"></div>
                        </div>
                    </div>
                    <div class="digit digit-0">
                        <div class="card">
                            <div class="card-face card-face-front"></div>
                            <div class="card-face card-face-back"></div>
                        </div>
                    </div>
                    <div class="digit digit-0">
                        <div class="card">
                            <div class="card-face card-face-front"></div>
                            <div class="card-face card-face-back"></div>
                        </div>
                    </div>
                    <div class="digit digit-0">
                        <div class="card">
                            <div class="card-face card-face-front"></div>
                            <div class="card-face card-face-back"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="flip-clock.js"></script>
    </body>
</html>
@56000 56000 changed the title Number Flip Counter Auto Number Flip Counter Nov 16, 2021
@1isten
Copy link
Owner

1isten commented Nov 16, 2021

There is a line with console.log inside the runClock function which logs the current time for your reference. If you want to stop the loop at some certain time, just return the function before the setTimeout execution.

For example if you want top stop when it is 14:30:00,

// ...

console.log(`${now.h0}${now.h1}:${now.m0}${now.m1}:${now.s0}${now.s1}`);

for (const t of Object.keys(els)) {
  // ...
}

// return the function
if (`${now.h0}${now.h1}:${now.m0}${now.m1}:${now.s0}${now.s1}` === '14:30:00') {
  return;
}
// the code below will not be executed, so the loop is stopped
setTimeout(runClock, 1000);

@56000
Copy link
Author

56000 commented Nov 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants