Skip to content

Commit

Permalink
#68 reuse keyframe instance
Browse files Browse the repository at this point in the history
  • Loading branch information
krazyjakee committed Feb 7, 2018
1 parent 301b09f commit f383a7c
Show file tree
Hide file tree
Showing 6 changed files with 2,082 additions and 143 deletions.
15 changes: 10 additions & 5 deletions dist/jquery.keyframes.js
Expand Up @@ -12,7 +12,12 @@ function _interopRequireDefault(obj) {
(function () {
var doForEach = function doForEach($el, cb) {
$el.each(function (index, elem) {
cb(new _core.default(elem));
if (elem.Keyframes) {
cb(elem.Keyframes);
} else {
elem.Keyframes = new _core.default(elem);
cb(elem.Keyframes);
}
});
};

Expand All @@ -23,25 +28,25 @@ function _interopRequireDefault(obj) {
};

$.fn.resetKeyframe = function (cb) {
doForEach($(this), function (kf) {
doForEach(this, function (kf) {
return kf.reset(cb);
});
};

$.fn.pauseKeyframe = function () {
doForEach($(this), function (kf) {
doForEach(this, function (kf) {
return kf.pause();
});
};

$.fn.resumeKeyframe = function () {
doForEach($(this), function (kf) {
doForEach(this, function (kf) {
return kf.resume();
});
};

$.fn.playKeyframe = function (frameOptions, callback) {
doForEach($(this), function (kf) {
doForEach(this, function (kf) {
return kf.play(frameOptions, callback);
});
};
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.keyframes.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/index.html
Expand Up @@ -33,9 +33,9 @@
'transform': 'rotate(450deg)'
}
}]);

});


function play(animation) {
$('.ball').resetKeyframe(function() {
switch (animation) {
Expand Down

0 comments on commit f383a7c

Please sign in to comment.