Git Product home page Git Product logo

css-spring's Introduction

About me

I'm an Engineering Manager at Cosuno. The web is my passion since 1996, when i developed my first website. I have a bachelor and a diploma in Computer Sciences, but everything I know about the web platform and cloud services today is self-taught. I consider myself blessed that I get to build great stuff and help others do the same for a living.

When not dabbling with web and cloud technology, I’m usually playing videogames or reading books or comics. I have slightly elitist views on beer, love to travel the world with my wife & daughter and have spent most of my adult life trying to get into a regular exercising habit. I believe in a culture that allows failure, supports experiments and celebrates learnings. I do some quality freelance consulting and teaching for Web Application Development, Web Security, SaaS and Cloud Architecture and write about Web Development and Cloud Technology on my Blog and Twitter.

Latest blog posts

  • Evaluation order of field initializers in JavaScript and TypeScript
    This article introduces you to my latest side project and describes a problem that I encountered because I did not understand the sequence between initializing class fields and calling a parent constructor. It then continues to explain how class fields are initialized in javascript and typescript and how I solved my initial problem.

  • How to create a self-updating GitHub profile README
    Profile READMEs are a new GitHub feature that allows user-defined content to be displayed on top of your GitHub profile page. This article explains how to create a basic README, shows few beautiful examples and explains how I've built mine to automatically update with my latest blog posts.

  • Generating beautiful Open Graph images with Node.js
    Open graph images provide nice previews when sharing your website. This article explains how to automatically generate open graph images with Node.js and integrate the results into a Gatsby site.

Build README

css-spring's People

Contributors

codepunkt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

css-spring's Issues

write tests

Work in progress

  • toPrecision
  • getInterpolator
  • parseDeclarations
  • getAnimationValues
  • sanitizeValues
  • addInterpolatedValues
  • buildKeyframeObject
  • main API

Issues with css values with ()

First of all, awesome little plugin! I've noticed that passing spring start and target values with () seems to break the code. At least thats my assumption.

Uncaught TypeError: Cannot convert undefined or null to object : css-spring.js:647

Lets say I want to translateX(50px), this won't work. I know I could use the "formatter" to fix this issue, but it would be awesome to just have start and target to be plain style objects.

Support array values

This should allow multi-value springs such as translate, translate3d or border-, margin- and padding-shorthands

import spring, { format } from 'css-spring'

const keyframes = spring(
  { translate3d: [ 0, 0, 0 ] },
  { translate3d: [ 250, -150, 0 ] },
  { preset: 'wobbly', precision: 5 }
)

const moveLeft = format(
  keyframes,
  (k, v) => `transform: ${k}(${v[0]} ${v[1]} ${v[2]});`
)

Object.values is not a function

I get the following error:

TypeError: Object.values is not a function
    at path/node_modules/css-spring/dist/css-spring.js:648:100

Here's the code I'm trying to run:

const spring = require('css-spring').default;
const springTest = spring({ left: '50px' }, { left: '250px' }, { preset: 'gentle' });

Combine different stiffness/damping for properties in the same animation

My initial thought was to allow this in the default API. I could not find a way to integrate it into the API that pleased me, though. What i tried was something along these lines:

const keyframes = spring(
  { 'margin-left': 0, opacity: 0, background: '#f00' },
  { 'margin-left': '250px', opacity: 1, background: '#bada55' },
  { preset: { 'margin-left': 'stiff', opacity: 'gentle' }}
);

You should also be able to set damping and stiffness individually, so they would follow the same pattern. Combine that with default and fallback values for properties that don't have explicit options defined and you've got a lot of configuration juggling and parsing and an API that is not pleasant to use.

Imho, this usecase can be solved in user-land - should it ever arise. E.g.:

import { merge } from 'lodash'

const stiff = spring({ 'margin-left': 0 }, { 'margin-left': '250px' }, { preset: 'stiff' })
const gentle = spring({ opacity: 0 }, { opacity: 1 }, { preset: 'gentle' })
const wobbly = spring({ background: '#f00' }, { background: '#bada55' })

const keyframes = merge({}, stiff, gentle, wobbly)

Optimize size

Properties that have the same values in subsequent keyframes can be eliminated. Keyframes that don't have any values left, can be eliminated aswell.

Examples don’t work

Really dig the idea here, but when I tried to get started and run on the examples, nothing was happening?

Unitless value with corresponding value that has a unit

Unitless value in either startProps or endProps should be interpreted as a value with a unit if the same property exists in the other argument with a given unit.

e.g. with
startProps { right: 0 }
endProps { right: '100px' }
the 0 in startProps should be interpreted as 0px.

Remove redundant values in consecutive keyframes

When consecutive keyframes have the same value for a css property, the latter ones can be omitted.

For example, if the 90% to 95% keyframes all have left: 20px and the 96% keyframe is the first one with a different left value, the 91% to 94% keyframes can omit the left declaration alltogether.

Plugin use cases: autoprefix, minify etc.

for style prefixing, inline-style-prefixer could be used. could also use cssnano (thanks @oliverturner for the idea) and autoprefixer postcss plugins - especially when performed at build time as opposed to runtime (needs babel/webpack plugins first)

Commandline

Adding a commandline to generate keyframe css for users that don't use css-in-js might be a good idea once the api has stabilized.

Strip out css units and automatically re-append them

css units always come after the numbers, so it should be easy to parse them and store them to the according properties. when given something like this

const data = spring(
  { left: '50em' }, { left: '250em' }, { preset: 'gentle' }
))

we could then animate from 50 to 250, store the em unit for the property left and re-apply that unit to the resulting keyframes.

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.