|
|
var tipTmpl = '<div class="tip {{tipClassName}}"><div class="title">{{title}}</div><div class="content">{{content}}</div><a class="button {{buttonClass}}">{{button}}</a></div>'
|
|
|
var toastTmpl = '<div style="{{style}}" class="feature-toast-content">{{content}}</div>';
|
|
|
var frameRate = 75; // 动画帧率
|
|
|
var showTip = function (data) {
|
|
|
var tipNode = null;
|
|
|
data = data || {
|
...
|
...
|
@@ -91,6 +92,9 @@ var toast = function (content, options) { |
|
|
}, (obj.duration && obj.duration > 0) ? obj.duration : 2000);
|
|
|
};
|
|
|
function fadeIn(el,time){
|
|
|
var mt = 1000 / frameRate,
|
|
|
opacityStep = mt / time;
|
|
|
|
|
|
if(el.style.opacity === ""){
|
|
|
el.style.opacity = 0;
|
|
|
}
|
...
|
...
|
@@ -98,17 +102,22 @@ function fadeIn(el,time){ |
|
|
el.style.display = 'block';
|
|
|
}
|
|
|
|
|
|
var t = setInterval(function(){
|
|
|
if(el.style.opacity < 1){
|
|
|
el.style.opacity = parseFloat(el.style.opacity)+0.01;
|
|
|
el.timer && clearInterval(el.timer);
|
|
|
el.timer = setInterval(function(){
|
|
|
if(el.style.opacity < 1 - opacityStep){
|
|
|
el.style.opacity = parseFloat(el.style.opacity) + opacityStep;
|
|
|
}
|
|
|
else{
|
|
|
clearInterval(t);
|
|
|
clearInterval(el.timer);
|
|
|
el.style.opacity = 1;
|
|
|
}
|
|
|
},time/100);
|
|
|
}, mt);
|
|
|
}
|
|
|
|
|
|
function fadeOut(el,time){
|
|
|
var mt = 1000 / frameRate,
|
|
|
opacityStep = mt / time;
|
|
|
|
|
|
if(el.style.opacity === ""){
|
|
|
el.style.opacity = 1;
|
|
|
}
|
...
|
...
|
@@ -116,15 +125,17 @@ function fadeOut(el,time){ |
|
|
el.style.display = 'block';
|
|
|
}
|
|
|
|
|
|
var t = setInterval(function(){
|
|
|
if(el.style.opacity > 0){
|
|
|
el.style.opacity = parseFloat(el.style.opacity)-0.01;
|
|
|
el.timer && clearInterval(el.timer);
|
|
|
el.timer = setInterval(function(){
|
|
|
if(el.style.opacity > opacityStep){
|
|
|
el.style.opacity = parseFloat(el.style.opacity) - mt / time;
|
|
|
}
|
|
|
else{
|
|
|
clearInterval(t);
|
|
|
clearInterval(el.timer);
|
|
|
el.style.opacity = 0;
|
|
|
el.style.display = 'none'
|
|
|
}
|
|
|
},time/100);
|
|
|
}, mt);
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
...
|
...
|
|