Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JavaScript animation

<!DOCTYPE html>
<html>
<style>
#container {
  width: 400px;
  height: 400px;
  border-radius: 10%;
  position: relative;
  background: rgb(130, 240, 231);
}
#animate {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid rgb(218, 15, 15);
  position: absolute;
  background-color: rgb(51, 255, 0);
}
</style>
<body>

<p><button onclick="myMove()">Click Me</button></p> 

<div id ="container">
  <div id ="animate"><br><p>(★‿★)</p></div>
  <br><br>
  <br><p>hello from mohammad alshraideh</p>
</div>

<script>
function myMove() {
  let id = null;
  const elem = document.getElementById("animate");   
  let pos = 0;
  clearInterval(id);
  id = setInterval(frame, 5);
  function frame() {
    if (pos == 350) {
      clearInterval(id);
    } else {
      pos++; 
      elem.style.top = pos + "px"; 
      elem.style.left = pos + "px"; 
    }
  }
}
</script>

</body>
</html>
Comment

js animations

<!DOCTYPE html>
<html>
<style>
#myContainer {
  width: 400px;
  height: 400px;
  position: relative;
  background: yellow;
}
#myAnimation {
  width: 50px;
  height: 50px;
  position: absolute;
  background-color: red;
}
</style>
<body>

<p>
<button onclick="myMove()">Click Me</button> 
</p>

<div id ="myContainer">
<div id ="myAnimation"></div>
</div>

<script>
var id = null;
function myMove() {
  var elem = document.getElementById("myAnimation");   
  var pos = 0;
  clearInterval(id);
  id = setInterval(frame, 10);
  function frame() {
    if (pos == 350) {
      clearInterval(id);
    } else {
      pos++; 
      elem.style.top = pos + 'px'; 
      elem.style.left = pos + 'px'; 
    }
  }
}
</script>

</body>
</html>
Comment

animation js

• pause() - Tạm thời đóng băng trạng thái hiện tại của animation
• play() - Tiếp tục thực hiện animation hoặc chạy lại animation trong trường hợp animation đã hoàn thành
• reverse() - thực hiện animation với chiều ngược lại
• finish() - Đi đến cuối của animation (đi đến đầu trong trường hợp sử dụng reverse)
• cancel() - Dừng animation và trở lại trạng thái đầu tiên trước khi thực hiện animation
Comment

animate js

const cdThumbAnimate = cdThumb.animate([
      { transform: 'rotate(360deg)' }
    ],{
      duration: 10000, // 10 seconds
      interation: Infinity
    })
Comment

PREVIOUS NEXT
Code Example
Javascript :: = meaning in javascript 
Javascript :: template literal 
Javascript :: flatpickr current date set to text field 
Javascript :: Manage selection fabric js 
Javascript :: emberjs cdn 
Javascript :: how to convert string to random case in javascript 
Javascript :: shopify liquid logic 
Javascript :: how to save data in javascript 
Javascript :: EACCES: permission denied /delete express.js 
Javascript :: jenkins javascript heap out of memory 
Javascript :: ternary operator multiple conditions 
Javascript :: javascript Adding Element to the Outer Array 
Javascript :: javascript Arrow Function with Promises and Callbacks 
Javascript :: javascript get() handler 
Javascript :: can i copy package-lock.json to another project 
Javascript :: react linkify 
Javascript :: jQuery Traversing - Ancestors 
Javascript :: promise limit time 
Javascript :: theme ui with react 17 
Javascript :: Json to npy file 
Javascript :: phaser animation repeat event 
Javascript :: add multiple phone using js 
Javascript :: npm deploy next js with tailwind 
Javascript :: JavaScript date format 2 
Javascript :: what is the syntax of putting an event listener in javascript mdn 
Javascript :: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 
Javascript :: forms in angular 
Javascript :: queryselector j 
Javascript :: javascript numbers 
Javascript :: Update an object as state with React hooks 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =