mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Fix snowfall plugin #434
This commit is contained in:
parent
a8eee1dbcf
commit
ab2a81cd9b
|
@ -4,7 +4,7 @@ class SnowfallOnLoginScreenPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Snowfall on login screen',
|
NAME = 'Snowfall on login screen',
|
||||||
VERSION = '2.0',
|
VERSION = '2.1',
|
||||||
CATEGORY = 'Fun',
|
CATEGORY = 'Fun',
|
||||||
DESCRIPTION = 'Snowfall on login screen (just for fun).';
|
DESCRIPTION = 'Snowfall on login screen (just for fun).';
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
|
|
||||||
if (!/iphone|ipod|ipad|android/i.test(navigator.userAgent))
|
if (!/iphone|ipod|ipad|android/i.test(navigator.userAgent))
|
||||||
{
|
{
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
if (window.snowFall && window.rl)
|
||||||
if (window.snowFall && window.rl && !rl.settings.get('Auth'))
|
{
|
||||||
{
|
let body = document.body;
|
||||||
window.snowFall.snow(document.getElementsByTagName('body'), {
|
addEventListener('sm-show-screen', e => {
|
||||||
shadow: true, round: true, minSize: 2, maxSize: 5
|
if ('login' == e.detail) {
|
||||||
});
|
window.snowFall.snow(body, {
|
||||||
}
|
shadow: true, round: true, minSize: 2, maxSize: 5
|
||||||
});
|
});
|
||||||
|
} else if (body.snow) {
|
||||||
|
body.snow.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Paul Irish requestAnimationFrame polyfill
|
// Paul Irish requestAnimationFrame polyfill
|
||||||
(function(window) {
|
(window => {
|
||||||
var lastTime = 0;
|
var lastTime = 0;
|
||||||
var vendors = ['webkit', 'moz'];
|
var vendors = ['webkit', 'moz'];
|
||||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||||
|
@ -57,11 +57,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.requestAnimationFrame)
|
if (!window.requestAnimationFrame)
|
||||||
window.requestAnimationFrame = function(callback, element) {
|
window.requestAnimationFrame = callback => {
|
||||||
var currTime = new Date().getTime();
|
var currTime = new Date().getTime();
|
||||||
var timeToCall = window.Math.max(0, 16 - (currTime - lastTime));
|
var timeToCall = window.Math.max(0, 16 - (currTime - lastTime));
|
||||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
var id = window.setTimeout(() => callback(currTime + timeToCall), timeToCall);
|
||||||
timeToCall);
|
|
||||||
lastTime = currTime + timeToCall;
|
lastTime = currTime + timeToCall;
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
@ -70,7 +69,7 @@
|
||||||
window.cancelAnimationFrame = function(id) {
|
window.cancelAnimationFrame = function(id) {
|
||||||
clearTimeout(id);
|
clearTimeout(id);
|
||||||
};
|
};
|
||||||
}(window));
|
})(window);
|
||||||
|
|
||||||
var snowFall = (function(){
|
var snowFall = (function(){
|
||||||
function jSnow(){
|
function jSnow(){
|
||||||
|
@ -248,28 +247,14 @@ var snowFall = (function(){
|
||||||
cancelAnimationFrame(snowTimeout);
|
cancelAnimationFrame(snowTimeout);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
return{
|
return{
|
||||||
snow : function(elements, options){
|
snow : (elements, options) => {
|
||||||
if(typeof(options) === 'string'){
|
if(typeof(options) === 'string'){
|
||||||
if(elements.length > 0){
|
elements.snow.clear();
|
||||||
for(var i = 0; i < elements.length; i++){
|
|
||||||
if(elements[i].snow){
|
|
||||||
elements[i].snow.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
elements.snow.clear();
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
if(elements.length > 0){
|
new jSnow().snow(elements, options);
|
||||||
for(var i = 0; i < elements.length; i++){
|
|
||||||
new jSnow().snow(elements[i], options);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
new jSnow().snow(elements, options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue