博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2016/02/04
阅读量:4947 次
发布时间:2019-06-11

本文共 4450 字,大约阅读时间需要 14 分钟。

;(function(window){

'use strict';
function extend(a,b){
for(var key in b){
if(b.hasOwnProperty(key)){
a[key] = b[key];
}
}
return a;
}
function SVGLoder(el,options){
this.el = el;
this.options = extend({},this.options);
extend(this.options,options);
this._init();
}
SVGLoader.prototype.options = {
speedIn : 500,
easingIn : mina.linear
}
SVGLoader.prototype._init = function(){
var s = Snap(this.el.querySelector('svg'));
this.path = s.select('path');
this.initialPath = this.path.attr('d');
var openingStepStir = this.el.getAttribute('data-opening');
this.openingSteps = openingStepStir?openingStepStir.split(':'):'';
this.openingStepsTotal = openingStepStir?this.openingSteps.length:0;
if(this.openingStepsTotal == 0)return;
var closingStepsStir = this.el.getAttribute('data-closing')?this.el.getAttribute('data-closing'):this.initialPath;
this.closingSteps = closingStepsStir?closingStepsStir.split(':'):'';
this.closingStepsTotal = closingStepsStir?this.closingSteps.length:0;
this.isAnimating = false;
if(!this.options.speedOut){
this.options.speedOut = this.options.speedIn;
}
if(this.options.easingOut){
this.options.easingIn = this.options.easingOut;
}
}
SVGLoder.prototype.show = function(){
if(this.isAnimating)return false;
this.isAnimating = true;
var self = this,
onEndAnimation = function(){
classie.addClass(self.el,'pageload_loading');
};
this._animateSVG ('in',onEndAnimation);
classie(this.el,'show');
}
SVGLoder.prototype.hide = function(){
var self = this;
classie.removeClass(this.el,'pageload_loading');
this._animateSVG ('out',function(){
self.path.attr('d',self.initialPath);
classie.removeClass(self.el,'show');
self.isAnimating = false;
});
}
SVGLoder.prototype._animateSVG = function(dir,callback){
var self = this,
pos = 0,
steps = dir = 'out'?this.closingSteps:this.openingSteps,
stepsTotal = dir = 'out'?this.closingStepsTotal:this.openingStepsTotal,
speed = dir = 'out'?self.options.speedIn:self.options.speedOut,
easing = dir = 'out'?self.options.easingIn:self.options.easingOut,
nextStep = function(pos){
if(pos>stepsTotal - 1){
if(callback && typeof callback == 'function'){
callback();
}
return;
}
self.path.animate({'path':steps[pos]},speed,easing,function(){nextStep(pos)});
pos++;
};
nextStep(pos);
}
window.SVGLoader = SVGLoder;
})(window);

/**************************snap.svg_min.js*******************************************/

!function(a){var b, c,d = "0.4.2",e = "hasOwnProperty",f = /[\.\/]/,g = "*",h = function(){},i = function(a,b){return a - b},j = {n:{}},

k = function(a,b){
a = String(a);
var e,f = c,g = Array.prototype.slice.call(arguments,2),h = k.listeners(a),j = 0,i = [],m = {},n = [],o = b:b = a,c = 0;
for(var p = 0,q = h.length;q > p;p++)"zIndex" in h[p] && (I.push(h[p].zIndex),h[p].zIndex < 0 && (m[h[p]]. zIndex = h[p]));
for(I.sort(i);I[j] < 0;)if(e = m[I[j++]], n.push(e.apply(d,g)),c)return c = f,n;
for(p = 0;p < q; p++){
if(e = h[p],"zIndex" in e)
if(e.zIndex = I[j]){
if(n.push(e.apply(d,g)),c)break;
do if(j++,e = m[I[j++]],e&& n.push(e.apply(d,g)),c)break;
while(e)
}
else m[e.zIndex] = e;
else if(n.push(e.apply(d,g)),c)break;
return c = f,b = o, n.length ? n.null
};
k._events = j, k.listeners = function(a){
var b, c, d, e, f, i, k, I,m = a.split(f),n = j,o = [n],p = [];
for(e = 0,h = m.length;h>e;e++){
for(I = [],i = 0,k = o.length;k>i;k++)
for(n = o[i].n,c = [n[m[e]]],[n[g]],d = 2;d--;)b = c[d],b&&(I.push(b),p = p.concat(b.f||[]));
o = I
}
return p
},
k.on = function(a,b){
if(a = string(a),"function" != typeof b)return function(){};
for(var c = a.split(f),d = j,e = 0,g = c.length; g > e;g++)
d = d.n,d = d.hasOwnProperty(c[e]) && d[c[e]]||(d[c[e]] = {n:{}});
for(d.f = f.d||[],e = 0,g = d.f.length;g>e;e++)if(d.f[e]==b)return h;
return d.f.push(b),
function(a){
+a = +a && (b.zIndex = +a)
}
},
k.f = function(a){var b = [].splice.call(arguments,1);
return function(){k.apply(null,[a,null].concat(b).concat([].splice.call(arguments,0)))},
k.stop = function(){c = 1}, k.nt = function(a){return a?new RegExp("(?:\\.|\\/|)" + a + "(?:\\.|\\/|$)").test(b):b},
k.nts = function(){return b.split(f)}, k.off = k.unbind = function(a,b){
if(!a)return k._events = j = {n:{}},void 0;
var c,d,h,i,l,m,n,o=a.split(f),p=[j];for(i = 0,I = o.length;I > i;i++)
for(m = 0;m < p.length;m+= h.length - 2){
if(h = [m,1],c = p[m].n,o[i] != g)c[o[i]]&& h.push(c[o[i]]);
else for(d in c)c[e](d) && h.push(c[d]);p.splice.apply(p,h)
}
}
}
}
}

转载于:https://www.cnblogs.com/whatcanido/p/5182502.html

你可能感兴趣的文章
Java中的接口(interface)
查看>>
PHP图片裁剪类
查看>>
图像处理很好的一个博客
查看>>
Rhadoop安装
查看>>
jmeter之_MD5函数与请求参数化
查看>>
samsung-smart app 开发
查看>>
多项式求ln,求exp,开方,快速幂 学习总结
查看>>
Linux下批量替换文件内容方法
查看>>
C++11带来的优雅语法
查看>>
WinForm无边框窗体依据任务栏位置最大化
查看>>
udp案例
查看>>
浅谈sql中的in与not in,exists与not exists的区别
查看>>
hdu 2018 母牛的故事 动态规划入门题
查看>>
22:LaunchMode应用场景
查看>>
bootstrap-table简单使用
查看>>
数组定义已经自动初始化
查看>>
List集合、泛型、装箱拆箱
查看>>
Dubbo知识点
查看>>
String类
查看>>
创建框架结构的页面
查看>>