Skip to content
프로젝트

소개

‘동작에서 효과로 이어지는’ 경로를 애니메이션으로 표현합니다.

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

cta.js npm version

A call to animate, your action-to-effect path


cta.js or "Call to Animation" is a light-weight performant library to animate any element ("action") onto any other element ("effect") on the page.

It is written with an aim to promote visual continuity in web apps. To see what you can do with this, checkout the demo:

DEMO

Installation

cta.js is just 1.2KB minified & gzipped.

  • Bower: bower install cta
  • NPM: npm install cta
  • Download zip.

Note: cta.js supports AMD and commonJS module pattern out of the box.

Usage

In very basic form, you can animate an element with selector X onto an element with selector Y:

var e1 = document.querySelector(X),
	e2 = document.querySelector(Y);
cta(e1, e2);

Triggering a reverse animation;

var e1 = document.querySelector('#js-source-element'),
	e2 = document.querySelector('#js-target-element');
var reverseAnimate = cta(e1, e2);

// Reverse previous animation. `options` and `callback` can be passed to this function too.
reverseAnimate();

Specify animation duration:

var e1 = document.querySelector('#js-source-element'),
	e2 = document.querySelector('#js-target-element');
cta(e1, e2, {
	duration: 0.3 // seconds
});

Specify a callback to execute after animation:

var button = document.querySelector('#js-button'),
	hiddenModal = document.querySelector('#js-modal');
cta(button, hiddenModal, function () {
	showModal();
});

More documentation coming up.

Public API

cta(sourceElement, targetElement [, options] [, callback] )

Animate an element sourceElement onto targetElement.

  • sourceElement - DOM Element which is the starting point of animation.
  • targetElement - DOM Element which is the end point of animation.
  • options - A map of additional options to control the animation behaviour.
    • duration - Duration (in seconds) of animation. Default is 0.3 seconds.
    • targetShowDuration - Duration (in seconds) of targetElement to become visible, if hidden initially. The library will automatically try to figure this out from the element's computed styles. Default is 0 seconds.
    • extraTransitionDuration - Extra duration (in seconds) of targetElement to provide visual continuity between the animation and the rendering of the targetElement. Default is 1 second.
    • relativeToWindow - Set to true if your target element is fixed positioned in the window. Default is relative to document (works good with normal elements).
  • callback - Optional callback to execute after animation completes.

Browser Support

cta.js works best on latest versions of Google Chrome, Firefox and Safari.

For all non-supported browsers, the library does nothing and fallbacks to normal behavior without any explicit handling in your code.

Contributing

Interested in contributing features and fixes?

Read more on contributing.

Changelog

See the Changelog

License

Copyright (c) 2015-2016 Kushagra Gour, http://kushagragour.in Licensed under the MIT license.

Credits

Paul Lewis - for his awesome performance tip on scaling elements.

관련 프로젝트 살펴보기

불러오는 중…