Skip to content

Adding support to @keyframes rule #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/Sabberworm/CSS/CSSList/KeyFrame.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Sabberworm\CSS\CSSList;


class KeyFrame extends CSSList {

private $vendorKeyFrame;
private $animationName;

public function __construct() {
parent::__construct();
$this->vendorKeyFrame = null;
$this->animationName = null;
}

public function setVendorKeyFrame($vendorKeyFrame) {
$this->vendorKeyFrame = $vendorKeyFrame;
}

public function getVendorKeyFrame() {
return $this->vendorKeyFrame;
}

public function setAnimationName($animationName) {
$this->animationName = $animationName;
}

public function getAnimationName() {
return $this->animationName;
}

public function __toString() {
$sResult = "@{$this->vendorKeyFrame} {$this->animationName} {";
$sResult .= parent::__toString();
$sResult .= '}';
return $sResult;
}

}
12 changes: 11 additions & 1 deletion lib/Sabberworm/CSS/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Sabberworm\CSS\CSSList\CSSList;
use Sabberworm\CSS\CSSList\Document;
use Sabberworm\CSS\CSSList\MediaQuery;
use Sabberworm\CSS\CSSList\Keyframe;
use Sabberworm\CSS\Property\Import;
use Sabberworm\CSS\Property\Charset;
use Sabberworm\CSS\RuleSet\AtRule;
Expand Down Expand Up @@ -88,7 +89,16 @@ private function parseAtRule() {
$this->consume('@');
$sIdentifier = $this->parseIdentifier();
$this->consumeWhiteSpace();
if ($sIdentifier === 'media') {
if($sIdentifier == '-webkit-keyframes' || $sIdentifier == '-moz-keyframes' || $sIdentifier == '-ms-keyframes' || $sIdentifier == '-o-keyframes' || $sIdentifier == 'keyframes') {
$oResult = new KeyFrame();
$oResult->setVendorKeyFrame($sIdentifier);
$oResult->setAnimationName(trim($this->consumeUntil('{')));
$this->consume('{');
$this->consumeWhiteSpace();
$this->parseList($oResult);
return $oResult;

} else if ($sIdentifier === 'media') {
$oResult = new MediaQuery();
$oResult->setQuery(trim($this->consumeUntil('{')));
$this->consume('{');
Expand Down