2017 © Pedro Peláez
 

library php-anim

CSS3 animation tool for PHP

image

mw/php-anim

CSS3 animation tool for PHP

  • Friday, January 3, 2014
  • by mweimerskirch
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHPAnim

CSS3 animation tool for PHP, (*1)

Advantages over writing the CSS manually: * No need to worry about CSS vendor prefixes, they are added automatically. * The animation times can be specified in seconds. The %-values for the keyframes are calculated automatically. * The animations can be generated using the full power of PHP: loops, values from a database, etc. * No performance penalties compared to using a JavaScript library to generate the CSS., (*2)

Installation

The tool does not provide an autoloader but follow the PSR-0 convention. You can use any compliant autoloader, for example the Symfony2 ClassLoader component., (*3)

If you use composer, adding something like this should be sufficient:, (*4)

<?php
require 'vendor/autoload.php';
use PHPAnim\Selector;
use PHPAnim\Animation;
use PHPAnim\Keyframe;

If you really want to use the tool standalone, you can manually require all the .php files in src/PHPAnim., (*5)

Usage

Following is a simple example of how to use the tool. Here, one or more HTML elements targeted by the CSS selector ".box" are animated from opacity 0 to opacity 1., (*6)

<style>
<?php
$selector = new Selector('.box');
$animation = $selector->createAnimation();
$animation
    ->addKeyframe(new KeyFrame(0, ['opacity' => 0]));
    ->addKeyframe(new Keyframe(5, ['opacity' => 1]));
echo $selector->toCSS();
?>
</style>

You can of course specify multiple CSS properties at the same time:, (*7)

new KeyFrame(0, ['opacity' => 0, 'margin' => '-200px 0 0 -200px']));

The animation name is generated randomly. You can optionally specify a custom name:, (*8)

$animation->setName('myAnimation');

If you want your animation to start after an initial delay, you can specify a delay (in seconds):, (*9)

// either in the constructor:
new Anmation(1.5);

// ... or by using a setter:
$animation->setDelay(1.5);

You can also set additional CSS properties for the animation. See the inline documentation for details., (*10)

$animation->setDirection(...);
$animation->setFillMode(...);
$animation->setIterationCount(...);
$animation->setPlayState(...);
$animation->setTimingFunction(...);

If you want to keep everything in one place, you can set initial CSS properties for your object., (*11)

$selector->setCSS([
    'background' => 'red',
    'height' => '100px',
    'width' => '100px',
]);

Instead of using CSS, you can also create animations using the "SimpleAnimation" class., (*12)

$animation = new SimpleAnimation();
$animation
    ->hide()
    ->moveTo(-100, -100)
    ->rotateTo(90)
    ->nextFrame(2.5)
    ->show()
    ->endFrame();
$selector->addAnimation($animation);

The Versions

03/01 2014

dev-master

9999999-dev

CSS3 animation tool for PHP

  Sources   Download

MIT

02/01 2014

dev-PathAnimation

dev-PathAnimation

CSS3 animation tool for PHP

  Sources   Download

MIT