Skip to content

Instantly share code, notes, and snippets.

@KeithNdhlovu
Created June 5, 2017 09:46
Show Gist options
  • Save KeithNdhlovu/bcc380327b097f26c0201609ccb15af4 to your computer and use it in GitHub Desktop.
Save KeithNdhlovu/bcc380327b097f26c0201609ccb15af4 to your computer and use it in GitHub Desktop.
Just a custom SVG loader animation
/**
* SVG Loader
* @template: '<div class="main-loader center" ng-show="showLoader"></div>'
*/
var Paper = Snap(".main-loader");
if (Paper !== null) {
Snap.load("loader.svg", function ( f ) {
Paper.append( f );
var S = Paper.select("#sustain");
var C = Paper.select("#consulting");
var animOne = S.select("#animation-one");
var animTwo = C.select("#animation-two");
function initAnimation (el, animEl, dur, dir) {
var bb = el.getBBox();
var cx = bb.x + ( bb.width / 2 );
var cy = bb.y + ( bb.height / 2 );
animEl.attr({
attributeName: "transform",
type: "rotate",
from: "0 " + cx + " " + cy,
to: 360 * dir + " " + cx + " " + cy,
dur: dur + "s",
repeatCount: "indefinite"
});
}
initAnimation(S, animOne, 2, 1);
initAnimation(C, animTwo, 3, -1);
});
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment