Giter Club home page Giter Club logo

starry_sky's Introduction

Starry Sky

Lars's Instructions

The star clicker I started at 16:19, I had it working and live by 17:23. That’s an hour and 4 minutes I think you can do it in 2.

Round 1

Move Element to Mouse Click Position

Calculating the mouse click position

Adjusting the position for any offsets, margins, and paddings

Setting a transform to move the element to the click point

Using a transition to animate the transform property

Source: https://www.kirupa.com/snippets/move_element_to_click_position.htm

Notes from Lars

The main difference between our code is that I used position relative/absolute to place the stars on the bodybody being the parent relative element.

I also placed a star by generating an HTML element to the page.

Then on rendering the element the animation is run.

And I have an event listener for animationend which removes the element from the page after the animation concludes.


Click events have a 200ms delay on touch screens. So I looked into touchstart, but then I was getting double stars. Turns out a touch event also triggers a click event, weird mobile behavior. That’s why I have some conditions set for that in my code.

If you have a click event handler on a touch screen, it takes 200ms to register because it looks for a touchstart first. It’s a built-in pause so if you want to get around that you have to listen to touchstart.

Look up

  • Animations
  • Transitions
  • transform property
  • Math.floor(), Math.random()

Notes

Source: https://zinoui.com/blog/css-transitions?

  • The normal behavior, when you change the state of an element, is to happen instantly. With using of CSS transitions, you can slow down the changes and adjust the effect how they will be applied.

**Source: **https://cssanimation.rocks/transition-vs-animation/

  • If you want to change an element from one state to another smoothly, a transition is a good choice.
  • CSS Animations are a more powerful alternative to transitions. Rather than rely on a change from one beginning state to an end state, animations can be made up of as many in-between states as you like, and offer more control over how the states are animated.

Resources

Lars's Color Resources

starry_sky's People

Contributors

mirhamasala avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.