ant-design/site/static/motionDemoLoad.js

79 lines
2.5 KiB
JavaScript
Raw Normal View History

/**
* Created by jljsj on 15/9/16.
*/
var TweenMax = TweenMax, Motion = Motion;
$(function () {
var needData = ["/static/TweenMax.min.js", "/static/motion.js"];
var loadFunc = {
num: 0,
numSub: function (_callback) {
this.num++;
if (this.num >= needData.length) {
if (typeof _callback === 'function') {
_callback();
}
} else {
this.getLoad(_callback);
}
},
getLoad: function (_callback) {
var self = this, str = needData[self.num];
if (str.indexOf(".js") >= 0) {
if ((str.indexOf('TweenMax') >= 0 && TweenMax) || (str.indexOf('motion.js') >= 0 && Motion)) {
self.numSub(_callback)
} else {
2015-09-17 18:05:06 +08:00
$.getScript(rootUrl + str, function () {
self.numSub(_callback)
})
}
}
}
};
var callback = function () {
Motion.motionVideo.init()
},
scripts = document.getElementsByTagName("script"),
urlData = [];
for (var i = 0; i < scripts.length; i++) {
var sc = scripts[i].src, str = sc.split('?')[1];
if (sc.indexOf('motionDemoLoad.js') >= 0 && str) {
var d = str.split('&');
2015-09-16 17:37:28 +08:00
urlData = d.map(function (s) {
return {name: s.split('=')[0], param: s.split('=')[1]};
});
}
}
2015-09-16 17:37:28 +08:00
urlData.map(function (m) {
if (m.param === 'easing') {
callback = function () {
new Motion("#J-Linear", {
lineData: [{stroke: "#f2666c"}, {
stroke: "#71B5DE",
openEaseName: "easeInOutQuad",
endEaseName: "easeInOutQuad"
}], mask: false
});
new Motion("#J-Symmetric", {
lineData: [
{openEaseName: "easeInOutQuad", endEaseName: "null", stroke: "#f2666c"},
{stroke: "#71B5DE", openEaseName: "easeInOutCubic", endEaseName: "easeInOutCubic"}],
mask: false, exposure: "top"
});
new Motion("#J-Entry", {
lineData: [
{openEaseName: "easeOutQuad", endEaseName: "easeOutQuad", stroke: "#f2666c"},
{stroke: "#71B5DE", openEaseName: "easeOutCubic", endEaseName: "easeInCubic"}],
mask: true, exposure: "bottom"
});
new Motion("#J-Back", {
lineData: [
{openEaseName: "easeOutBounce", endEaseName: "easeOutElastic", stroke: "#70f266"},
{stroke: "#71B5DE", openEaseName: "easeOutBack", endEaseName: "easeInOutBack"}],
mask: false, exposure: "top"
});
}
}
});
loadFunc.getLoad(callback);
});