Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
create-transition
Advanced tools
Readme
Create transition animations that CSS can't.
https://jiangfengming.github.io/create-transition/examples/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>create-transition</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
height: 9999px;
background-image: linear-gradient(to bottom, rgba(255,255,0,0.5), rgba(0,0,255,0.5));
}
.fixed {
position: fixed;
top: 10px;
left: 10px;
}
.box {
margin-top: 2000px;
width: 200px;
height: 200px;
background: #FF2F92;
}
</style>
</head>
<body>
<div class="fixed">
<p><input type="text" id="num" value="0"></p>
<button id="scrollToTop">scroll to top</button>
<button id="scrollToBottom">scroll to bottom</button>
<button id="scrollToBox">scroll to box</button>
<button id="inc">increase</button>
<button id="dec">decrease</button>
</div>
<div class="box"></div>
<script type="module">
import { createTransition, easeInOutQuad, easeInOutCubic } from 'https://unpkg.com/create-transition'
document.getElementById('scrollToTop').addEventListener('click', scrollToTop)
document.getElementById('scrollToBottom').addEventListener('click', scrollToBottom)
document.getElementById('scrollToBox').addEventListener('click', () =>
scrollToElement(document.querySelector('.box'), 150)
)
document.getElementById('inc').addEventListener('click', inc)
document.getElementById('dec').addEventListener('click', dec)
function scrollToElement(el, offset = 0) {
const y = window.scrollY
const d = el.getBoundingClientRect().top - offset
createTransition(t => window.scrollTo(0, y + t * d), 300, easeInOutQuad)
}
function scrollToTop() {
const y = window.scrollY
createTransition(t => window.scrollTo(0, y - t * y), 300, easeInOutQuad)
}
function scrollToBottom() {
const y = window.scrollY
const d = document.documentElement.scrollHeight - window.innerHeight - window.scrollY
createTransition(t => window.scrollTo(0, y + t * d), 300, easeInOutQuad)
}
function inc() {
const num = document.getElementById('num')
const n = parseInt(num.value) || 0
createTransition(t => num.value = n + Math.round(100 * t), 2000, easeInOutCubic)
}
function dec() {
const num = document.getElementById('num')
const n = parseInt(num.value) || 0
createTransition(t => num.value = n - Math.round(100 * t), 2000, easeInOutCubic)
}
</script>
</body>
</html>
import { createTransition, easeInOutQuad /* , ...other easing functions */} from 'create-transition'
If you don't need easing functions:
import createTransition from 'create-transition'
Creates a transition between two states. It uses requestAnimationFrame underneath.
animate(o)
Function. The animation function to run per frame. o
is the eased value computed by easing(t)
.
duration
Number. The number of milliseconds a transition animation should take to complete.
easing(t)
Function. A mathematical function that describes how fast one-dimensional values change during animations.
This lets you vary the animation's speed over the course of its duration. See more about easing functions:
<timing-function>
and
Improved Easing Functions
t
: Number. t = (currentTime - startTime) / duration
. It represents the percentage of completeness of the transition.
It's value is between 0 and 1.
The return value is the eased value of t
. 0.0
represents the initial state, and 1.0
represents the final state.
Depending on the specific function used, the calculated output can sometimes grow to be greater than 1.0 or smaller
than 0.0 during the course of an animation. This causes the animation to go farther than the final state, and then
return. For some properties, such as left or right, this creates a kind of "bouncing" effect.
Example easing function:
function easeInQuad(t) {
return t * t
}
You can create easing functions using bezier-easing.
Generates an easeInBack function with custom amount
.
Generates an easeOutBack function with custom amount
.
Generates an easeInOutBack function with custom amount
.
Generates an easeInElastic function with custom amplitude
and period
.
Generates an easeOutElastic function with custom amplitude
and period
.
Generates an easeInOutElastic function with custom amplitude
and period
.
generateEaseInBack(1.7)
)generateEaseOutBack(1.7)
)generateEaseInOutBack(1.7 * 1.525)
)generateEaseInElastic(1, 0.3)
)generateEaseOutElastic(1, 0.3)
)generateEaseInOutElastic(1, 0.3 * 1.5)
)Easing functions are collected from:
FAQs
Create transitions that CSS can't.
The npm package create-transition receives a total of 5 weekly downloads. As such, create-transition popularity was classified as not popular.
We found that create-transition demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.