zaceno / hyperapp-transitions Goto Github PK
View Code? Open in Web Editor NEWAnimate Hyperapp components as they are appear, disappear and move around on the page.
License: MIT License
Animate Hyperapp components as they are appear, disappear and move around on the page.
License: MIT License
Hi there again :) I'm currently unavailable to ultradom because of this jorgebucaran/superfine#66
Is it possible to use another virtual-dom library for this awesome transition-library, like https://github.com/yelouafi/petit-dom? What is required for the virtual-dom library, to implement oncreate, ondelete hooks? Possibility to supply style as an object? Would be awesome with some documentation of how to get it to work.
By the way, I love the new API, crystal clear ๐ฅ ๐ ๐
And by the way n.2 shouldn't the default easing be 'ease-in-out'? That's the default in the browser and is used by 2/3 of your examples ๐
When I use hyperapp/transitions with the following code:
import { Enter, Exit } from "transitions"
import { h } from 'hyperapp';
export const Home = () => (state, actions) => (
<Enter easing="ease-in-out" css={{opacity: "0"}}>
<Exit easing="ease-in-out" css={{opacity: "0", transform: "scale(2.0,2.0)"}}>
<div key="home"><h1>Home</h1></div>
</Exit>
</Enter>);
It is not showing any transitions, and it is rendering as the following:
<undefined easing="ease-in-out" css="[object Object]">
<undefined easing="ease-in-out" css="[object Object]">
<div>
<h1>Home</h1>
</div>
</undefined>
</undefined>
I am using:
hyperapp/transitions: 1.0.2
hyperapp: 1.2.5
Is this a bug, or a mistake on my part?
https://codepen.io/zaceno/pen/XzOwPd
If you use 1000ms
time or so, and you click the button relatively fast, you'll notice glitchy behavior/transitions, due to the fact that timeouts aren't cleared if there are pending ones.
function runTransition (el, attr, before, after, ondone) {
var easing = attr.easing || 'linear'
var time = attr.time || 300
var delay = attr.delay || 0
setStyle(el, before)
setTimeout(function () {
requestAnimationFrame(function () {
setStyle(el, after)
el.style.transition = 'all ' + easing + ' ' + time + 'ms'
// HERE:
// clear current pending timeout (if any) before setting another timeout
setTimeout(function () {
el.style.transition = null
ondone && ondone()
}, time)
})
}, delay)
}
Is there any reason the order of transitions should matter?
I'm finding that the following skips the entry transition:
<transitions.enter time={ 500 } css={ { opacity: '0' } }>
<transitions.exit time={ 500 } css={ _ => ({ opacity: '0' }) }>
<div key={ id } ></div>
</transitions.exit>
</transitions.enter>
but if exit is on the outside it works fine:
<transitions.exit time={ 500 } css={ _ => ({ opacity: '0' }) }>
<transitions.enter time={ 500 } css={ { opacity: '0' } }>
<div key={ id } ></div>
</transitions.enter>
</transitions.exit>
Have you come across this behaviour? Is it intentional?
The examples here are broken due to the change of the api in ultradom...
When you only use a move transition (no exit transition), it makes it so the element does not dissapear when the node is removed.
Until I fix this the workaround is to use:
onremove: (el, done) => done()
on the transitioned node, to make it removable.
Seems the 3 examples all use jsx. Do we need to do something special to make it work with @hyperapp/html?
The latest update to hyperapp introduced a bug in transitions, you can notice in the toasts example when toasts are removed. (Janky behavior)
This is a sweet little minimal lib, just wanted to say thanks, great work!
picodom is using onremove
while hyperapp is using onbeforeremove
, transitions's exit only support onbeforeremove
.
If scroll changes while nodes are 'leaving', their transform matrix takes into account any change in scroll position
Edit: after looking at the source is seems that a change in scroll position while a node is being acted on by _leaveOnRemove
the change is captured as a transform (here) and then applied to the node (here)
Cool library, are you using FLIP transitions for this?
The first message is not transitioned down smoothly.
The route https://unpkg.com/@hyperapp/transitions doesn't work,
But this work:
https://unpkg.com/@hyperapp/[email protected]/dist/transitions.js
So the codepen examples are broken..
This is incompatible with newer hyperapp versions since 0.12.0 I think, because the vdom changed the name of the data
property of a vnode to props
. In hyperapp -- but not yet in picodom
So the steps to fix this are:
[ ] replace all .data
with .props
in picodom
[ ] replace all .data
with .props
in hyperapp-transitions
I've created a little learning project with hyperapp and @hyperapp/transitions and have run into a strange issue. When adding some of the larger quotes, the containing blockquote
element appears to only partially paint. If I do anything to alter the screen (i.e. show the browsers toolbar, hover elements in the devtools inspector, tab away and back, highlight the text with ctrl
+ a
or whatever) it will snap to the correct render.
Just click the quote on the demo and sometimes the larger quotes will reproduce the issue.
I'm using Firefox Quantum 60.0.2 on Ubuntu MATE. Let me know if you need more info.
when i use with @hyperapp/router, there is no animation, and it shows โ[object Object]โ
it's my code:
import {h, app} from "hyperapp" // 1.2.5
import {Link, Route, location} from "@hyperapp/router" // 0.7.0
import {Enter, Exit} from "@hyperapp/transitions" // 1.0.2
const Home = () =>
<Enter css={{opacity: "0"}}>
<Exit css={{opacity: "0", transform: "scale(2.0,2.0)"}}>
<h2>Home</h2>
</Exit>
</Enter>
const About = () =>
<Enter css={{opacity: "0"}}>
<Exit css={{opacity: "0", transform: "scale(2.0,2.0)"}}>
<h2>About</h2>
</Exit>
</Enter>
const state = {
location: location.state
};
const actions = {
location: location.actions
};
const view = state => (
<div>
<Link to="/">Home</Link>
<Link to="/about">About</Link>
<hr/>
<Route path="/" render={Home}/>
<Route path="/about" render={About}/>
</div>
);
const main = app(state, actions, view, document.body)
const unsubscribe = location.subscribe(main.location)
I found the examples a bit tricky to read, I suggest improving them as follows:
_
for paramless functionsadd
, always place the new message at the beginning of the array so it appears on top - it's confusing having it appear randomly in the order (to me)Here is Toasts:
const { h, app } = hyperapp
const { Move, Enter, Exit } = transitions
/** @jsx h */
const Toast = ({ message, remove }, children) => (
<Move easing="ease-in-out">
<Exit
easing="ease-in-out"
css={{ transform: "scale(2.0, 2.0)", opacity: "0" }}
>
<Enter
easing="ease-in-out"
css={{ transform: "translateX(100%)", opacity: "0" }}
>
<div class="message" key={message} onclick={() => remove(message)}>
{message}
</div>
</Enter>
</Exit>
</Move>
)
const state = {
messages: []
}
const actions = {
add: () => state => {
const newMessage = btoa("" + Math.random()).slice(3, 11)
return { messages: [newMessage, ...state.messages] }
},
remove: message => state => ({
messages: state.messages.filter(m => m !== message)
}),
reset: () => ({ messages: [] }),
shuffle: () => state => {
const messages = [...state.messages]
let m = messages.length
while (m) {
const i = Math.floor(Math.random() * m--)
;[messages[m], messages[i]] = [messages[i], messages[m]]
}
return { messages }
}
}
const view = (state, actions) => (
<main class="app">
<button onclick={actions.add}>Add</button>
<button onclick={actions.reset}>Reset</button>
<button onclick={actions.shuffle}>Shuffle</button>
Click toasts to remove them.
<div class="messages">
{state.messages.map(message => (
<Toast message={message} remove={actions.remove} />
))}
</div>
</main>
)
app(state, actions, view, document.body)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.