Created
June 5, 2017 09:46
-
-
Save KeithNdhlovu/bcc380327b097f26c0201609ccb15af4 to your computer and use it in GitHub Desktop.
Just a custom SVG loader animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment