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

Question to “template” #97

Open
7u5a opened this issue May 9, 2024 · 3 comments
Open

Question to “template” #97

7u5a opened this issue May 9, 2024 · 3 comments

Comments

@7u5a
Copy link

7u5a commented May 9, 2024

How is it possible to make a live clock?

@tobiasandersen
Copy link
Contributor

We have a helper useClock() hook here: https://github.com/nxtedition/create-caspar-graphics/blob/master/packages/graphics-kit/src/use-clock.js. We haven't documented this one yet, but it can be used similar to the other hooks as described here: https://gfx.nxtedition.com/docs/hooks/use-image.

@7u5a
Copy link
Author

7u5a commented May 16, 2024

Tryed this, but does not seem to work?
Ur.zip

@tobiasandersen
Copy link
Contributor

It's close, but the options passed to it should be as described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat.

This is probably what you want:

const GsapUr = () => {
  const ur = useClock("da-DK", { hour: 'numeric', minute: 'numeric' })

  return (
    <GsapTimeline
      hide={!ur}
      onPlay={timeline => {
        timeline.from('#ur', { opacity: 0 })
      }}
      onStop={timeline => {
        timeline.to('#ur', { opacity: 0 })
      }}
    >
      <div id="ur">
        {ur}
      </div>
    </GsapTimeline>
  )
}

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