-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3241 from sandhose/snow
Ajout de neige pour Noël
- Loading branch information
Showing
15 changed files
with
209 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
var LetItSnow = function(element) { | ||
this._parent = element; | ||
|
||
this._canvas = document.createElement("canvas"); | ||
this.resize(); | ||
|
||
this._canvas.style.zIndex = -1; | ||
this._canvas.style.position = "absolute"; | ||
this._canvas.style.top = this._canvas.style.left = this._canvas.style.right = this._canvas.style.bottom = 0; | ||
|
||
this._canvas.style.background = window | ||
.getComputedStyle(this._parent) | ||
.getPropertyValue("background-color"); | ||
this._parent.style.background = "transparent"; | ||
|
||
// Append the canvas... | ||
if(this._parent.children.length > 0) { // As first element if there is other children | ||
this._parent.insertBefore(this._canvas, this._parent.children[0]); | ||
} | ||
else { | ||
this._parent.appendChild(this._canvas); | ||
} | ||
|
||
this._ctx = this._canvas.getContext("2d"); | ||
|
||
this.setup(); | ||
}; | ||
|
||
LetItSnow.prototype = { | ||
PARTICLES_COLOR: "rgba(255, 255, 255, 0.8)", // Color | ||
MAX_PARTICLES: 25, // Particles limits | ||
SPAWN_RATE: 100, // time (ms) between two particles spawns | ||
PARTICLES_SPEED: 15, // Base speed | ||
PARTICLES_SIZE: 2, // Base size | ||
TURBULENCES_X: 1, // Turbulences amount (X) | ||
TURBULENCES_Y: 0.5, // Turbulences amount (Y) | ||
TURBULENCES_SPEED: 1, // Turbulences speed | ||
MAX_TIMESHIFT: Math.PI / 3, // Max time shifting (turbulences) between two particles | ||
|
||
setup: function() { | ||
this.particles = []; | ||
this._lastSpawn = this._lastLoop = Date.now(); | ||
this.loop(); | ||
|
||
window.addEventListener("resize", this.resize.bind(this)); | ||
}, | ||
|
||
resize: function() { | ||
var rect = this._parent.getBoundingClientRect(); | ||
|
||
this.H = rect.height; | ||
this.W = rect.width; | ||
|
||
this._canvas.height = this.H; | ||
this._canvas.width = this.W; | ||
}, | ||
|
||
spawnParticle: function() { | ||
this.particles.push({ | ||
x: Math.random() * this.W, | ||
y: - this.PARTICLES_SIZE, | ||
d: Math.random() + 1, // Density (affects speed and size) | ||
s: Math.random() * this.MAX_TIMESHIFT // Time shift | ||
}); | ||
}, | ||
|
||
loop: function() { | ||
this.update(); | ||
this.draw(); | ||
|
||
requestAnimationFrame(this.loop.bind(this)); | ||
}, | ||
|
||
update: function() { | ||
var p, now = Date.now(), delta = now - this._lastLoop; | ||
for(var i in this.particles) { | ||
p = this.particles[i]; | ||
p.y += (delta / 1000) * (this.PARTICLES_SPEED * p.d * (1.5 + Math.sin(now * this.TURBULENCES_SPEED / 1000 + p.s) * this.TURBULENCES_Y)); | ||
p.x += (delta / 1000) * (this.PARTICLES_SPEED * p.d * (Math.cos(now * this.TURBULENCES_SPEED / 1000 + p.s) * this.TURBULENCES_X)); | ||
|
||
if(p.y - (p.d * 4) > this.H || p.x - (p.d * 4) > this.W || p.x + (p.d * 4) < 0) { | ||
this.particles.splice(i, 1); | ||
} | ||
} | ||
|
||
if(this._lastSpawn <= now - this.SPAWN_RATE && this.particles.length < this.MAX_PARTICLES) { | ||
this._lastSpawn = now; | ||
this.spawnParticle(); | ||
} | ||
|
||
this._lastLoop = now; | ||
}, | ||
|
||
draw: function() { | ||
this._ctx.clearRect(0, 0, this.W, this.H); | ||
|
||
this._ctx.fillStyle = this.PARTICLES_COLOR; | ||
this._ctx.beginPath(); | ||
|
||
var p; | ||
for(var i in this.particles) { | ||
p = this.particles[i]; | ||
|
||
this._ctx.moveTo(p.x, p.y); | ||
this._ctx.arc(p.x, p.y, p.d * this.PARTICLES_SIZE, 0, Math.PI*2, true); | ||
} | ||
|
||
this._ctx.fill(); | ||
} | ||
}; | ||
|
||
window.addEventListener("DOMContentLoaded", function() { | ||
if(document.body.className.split(" ").indexOf("vc-snow") !== -1) { // No jQuery here | ||
setTimeout(function() { | ||
window.snow = new LetItSnow(document.querySelector(".header-container > header")); | ||
}, 1000); // to be sure to have the DOM completely ready | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,5 +34,11 @@ | |
|
||
.home .home-search-box::before { | ||
background-image: url('../images/[email protected]'); | ||
|
||
@at-root { | ||
body.vc-clem-christmas.home .home-search-box::before { | ||
background-image: url('../images/[email protected]'); | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,6 +223,12 @@ $content-width: 1145px; | |
background-size: 100%; | ||
width: 68px; | ||
height: 134px; | ||
|
||
@at-root { | ||
body.vc-clem-christmas.home .home-search-box::before { | ||
background-image: url('../images/[email protected]'); | ||
} | ||
} | ||
} | ||
|
||
label, input { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
zds/member/migrations/0004_profile_allow_temp_visual_changes.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('member', '0003_auto_20151019_2333'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='profile', | ||
name='allow_temp_visual_changes', | ||
field=models.BooleanField(default=True, verbose_name=b'Activer les changements visuels temporaires'), | ||
preserve_default=True, | ||
), | ||
] |
This file contains 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
This file contains 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
This file contains 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