Một mục mã nguồn mở trong kho dữ liệu GitHub của TopGit: michaelvillar/dynamics.js, 7.5k sao, CoffeeScript. Javascript library to create physics-based animations
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
var path = document.querySelector("path")
dynamics.animate(path, {
d: "M0,0 L0,100 L100,50 L0,0 Z",
fill: "#FF0000",
rotateZ: 45,
// rotateCX and rotateCY are the center of the rotation
rotateCX: 100,
rotateCY: 100
}, {
friction: 800
})
Animates an element to the properties with the animation options.
el is a DOM element, a JavaScript object or an Array of elements
properties is an object of the properties/values you want to animate
options is an object representing the animation
type is the animation type: dynamics.spring, dynamics.easeInOut,... (default: dynamics.easeInOut)
frequency, friction, bounciness,... are specific to the animation type you are using
duration is in milliseconds (default: 1000)
delay is in milliseconds (default: 0)
complete (optional) is the completion callback
change (optional) is called at every change. Two arguments are passed to the function. function(el, progress)
el is the element it's animating
progress is the progress of the animation between 0 and 1
dynamics.stop(el)
Stops the animation applied on the element
dynamics.css(el, properties)
This is applying the CSS properties to your element with the correct browser prefixes.
el is a DOM element
properties is an object of the CSS properties
dynamics.setTimeout(fn, delay)
Dynamics.js has its own setTimeout. The reason is that requestAnimationFrame and setTimeout have different behaviors. In most browsers, requestAnimationFrame will not run in a background tab while setTimeout will. This can cause a lot of problems while using setTimeout along your animations. I suggest you use Dynamics's setTimeout and clearTimeout to handle these scenarios.
fn is the callback
delay is in milliseconds
Returns a unique id
dynamics.clearTimeout(id)
Clears a timeout that was defined earlier
id is the timeout id
dynamics.toggleSlow()
Toggle a debug mode to slow down every animations and timeouts.
This is useful for development mode to tweak your animation.
This can be activated using Shift-Control-D in the browser.
Dynamics and properties
dynamics.spring
frequency default is 300
friction default is 200
anticipationSize (optional)
anticipationStrength (optional)
dynamics.bounce
frequency default is 300
friction default is 200
dynamics.forceWithGravity and dynamics.gravity
bounciness default is 400
elasticity default is 200
dynamics.easeInOut, dynamics.easeIn and dynamics.easeOut
friction default is 500
dynamics.linear
No properties
dynamics.bezier
points array of points and control points
The easiest way to output this kind of array is to use the curve creator. Here is an example:
Some code from Sylvester.js has been used (part of Vector and Matrix).
License
The MIT License (MIT)
Copyright (c) 2015 Michael Villar
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/michaelvillar/dynamics.js là nguồn chính thức.
michaelvillar/dynamics.js có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho michaelvillar/dynamics.js. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
michaelvillar/dynamics.js có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho michaelvillar/dynamics.js. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
michaelvillar/dynamics.js có trang demo không?
Dự án có trang chủ ở http://dynamicsjs.com. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
michaelvillar/dynamics.js còn đang phát triển không?
Commit gần nhất trên michaelvillar/dynamics.js là 7.5 năm trước (theo timestamp GitHub). Repo có 402 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
dynamics.js có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về dynamics.js.