-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated jquery.snow.js to the latest. Added two more color options: you can now have three different colors on the flakes. Added option to change the dingbat used: you now have 20 different characters to choose from. Changed the default values of the snowflake sizes a bit. Changed the z-index to 20 instead of 999! Using <div class="flake"> instead of <div=id"flake"> since ID should be unice.
- Loading branch information
1 parent
6fb0dee
commit 4bb6819
Showing
6 changed files
with
152 additions
and
31 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.
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,77 @@ | ||
/** | ||
* jquery.snow - jQuery Snow Effect Plugin | ||
* | ||
* Available under MIT licence | ||
* | ||
* @version 1 (21. Jan 2012) | ||
* @author Ivan Lazarevic | ||
* @requires jQuery | ||
* @see http://workshop.rs | ||
* | ||
* @params flakeChar - the HTML char to animate | ||
* @params minSize - min size of snowflake, 10 by default | ||
* @params maxSize - max size of snowflake, 20 by default | ||
* @params newOn - frequency in ms of appearing of new snowflake, 500 by default | ||
* @params flakeColors - array of colors , #FFFFFF by default | ||
* @params durationMillis - stop effect after duration | ||
* @example $.fn.snow({ maxSize: 200, newOn: 1000 }); | ||
*/ | ||
(function($){ | ||
|
||
$.fn.snow = function(options){ | ||
|
||
var $flake = $('<div class="flake" />').css({'position': 'absolute', 'top': '-50px'}), | ||
documentHeight = $(document).height(), | ||
documentWidth = $(document).width(), | ||
defaults = { | ||
flakeChar : "❄", | ||
minSize : 10, | ||
maxSize : 20, | ||
newOn : 500, | ||
flakeColor : ["#ffffff"], | ||
durationMillis: null | ||
}, | ||
options = $.extend({}, defaults, options); | ||
|
||
$flake.html(options.flakeChar); | ||
|
||
var interval = setInterval( function(){ | ||
var startPositionLeft = Math.random() * documentWidth - 100, | ||
startOpacity = 0.5 + Math.random(), | ||
sizeFlake = options.minSize + Math.random() * options.maxSize, | ||
endPositionTop = documentHeight - defaults.maxSize - 40, | ||
endPositionLeft = startPositionLeft - 100 + Math.random() * 200, | ||
durationFall = documentHeight * 10 + Math.random() * 5000; | ||
$flake | ||
.clone() | ||
.appendTo('body') | ||
.css( | ||
{ | ||
left: startPositionLeft, | ||
opacity: startOpacity, | ||
'font-size': sizeFlake, | ||
color: options.flakeColor[Math.floor((Math.random() * options.flakeColor.length))] | ||
} | ||
) | ||
.animate( | ||
{ | ||
top: endPositionTop, | ||
left: endPositionLeft, | ||
opacity: 0.2 | ||
}, | ||
durationFall, | ||
'linear', | ||
function() { | ||
$(this).remove() | ||
} | ||
); | ||
}, options.newOn); | ||
|
||
if (options.durationMillis) { | ||
setTimeout(function() { | ||
removeInterval(interval); | ||
}, options.durationMillis); | ||
} | ||
}; | ||
|
||
})(jQuery); |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
/** | ||
* jquery.snow - jQuery Snow Effect Plugin | ||
* | ||
* Available under MIT licence | ||
* | ||
* @version 1 (21. Jan 2012) | ||
* @author Ivan Lazarevic | ||
* @requires jQuery | ||
* @see http://workshop.rs | ||
* | ||
* @params flakeChar - the HTML char to animate | ||
* @params minSize - min size of snowflake, 10 by default | ||
* @params maxSize - max size of snowflake, 20 by default | ||
* @params newOn - frequency in ms of appearing of new snowflake, 500 by default | ||
* @params flakeColors - array of colors , #FFFFFF by default | ||
* @params durationMillis - stop effect after duration | ||
* @example $.fn.snow({ maxSize: 200, newOn: 1000 }); | ||
*/ | ||
(function($){$.fn.snow = function(options){var $flake = $('<div class="flake" style="z-index:20;" />').css({'position': 'absolute', 'top': '-50px'}),documentHeight= $(document).height(),documentWidth= $(document).width(),defaults= {flakeChar: "❄", minSize: 10,maxSize: 20, newOn: 500, flakeColor: ["#ffffff"], durationMillis: null},options = $.extend({}, defaults, options);$flake.html(options.flakeChar);var interval = setInterval( function(){var startPositionLeft = Math.random() * documentWidth - 100,startOpacity = 0.5 + Math.random(),sizeFlake = options.minSize + Math.random() * options.maxSize,endPositionTop = documentHeight - defaults.maxSize - 40,endPositionLeft = startPositionLeft - 100 + Math.random() * 200,durationFall = documentHeight * 10 + Math.random() * 5000;$flake.clone().appendTo('body').css({left: startPositionLeft,opacity: startOpacity,'font-size': sizeFlake,color: options.flakeColor[Math.floor((Math.random() * options.flakeColor.length))]}).animate({top: endPositionTop,left: endPositionLeft,opacity: 0.2},durationFall,'linear',function() {$(this).remove()});}, options.newOn);if (options.durationMillis) {setTimeout(function() {removeInterval(interval);}, options.durationMillis);}};})(jQuery); |
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 |
---|---|---|
@@ -1,37 +1,77 @@ | ||
{ | ||
"name": "Let It Snow", | ||
"description": "Let it snow on your site", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"demo": "http://varoystrand.se/sidor/let-it-snow-for-koken/", | ||
"author": { | ||
"name": "Bjarne Varoystrand", | ||
"link": "http://varoystrand.se/" | ||
}, | ||
|
||
"data": { | ||
"let_it_snow_char": { | ||
"label": "Flake character", | ||
"info": "Character used for the flake. See http://www.w3schools.com/charsets/ref_utf_dingbats.asp for reference.", | ||
"type": "select", | ||
"options": [ | ||
{ "label": "Sparkles", "value": "✨" }, | ||
{ "label": "Open centre asterisk", "value": "✲" }, | ||
{ "label": "Eight spoked asterisk", "value": "✳" }, | ||
{ "label": "Eight pointed pinwheel star", "value": "✵" }, | ||
{ "label": "Teardrop-spoked asterisk", "value": "✻" }, | ||
{ "label": "Open centre teardrop-spoked asterisk", "value": "✼" }, | ||
{ "label": "Heavy teardrop-spoked asterisk", "value": "✽" }, | ||
{ "label": "Six petalled black and white florette", "value": "✾" }, | ||
{ "label": "Black florette", "value": "✿" }, | ||
{ "label": "White florette", "value": "❀" }, | ||
{ "label": "Eight petalled outlined black florette", "value": "❁" }, | ||
{ "label": "Heavy teardrop-spoked pinwheel asterisk", "value": "❃" }, | ||
{ "label": "Snowflake", "value": "❄" }, | ||
{ "label": "Tight trifoliate snowflake", "value": "❅" }, | ||
{ "label": "Heavy chevron snowflake", "value": "❆" }, | ||
{ "label": "Sparkle", "value": "❇" }, | ||
{ "label": "Heavy sparkle", "value": "❈" }, | ||
{ "label": "Balloon-spoked asterisk", "value": "❉" }, | ||
{ "label": "Eight teardrop-spoked propeller asterisk", "value": "❊" }, | ||
{ "label": "Heavy eight teardrop-spoked propeller asterisk", "value": "❋" } | ||
], | ||
"value": "❄" | ||
}, | ||
"let_it_snow_minsize": { | ||
"label": "Min size", | ||
"info": "Min size of snowflake.", | ||
"type": "number", | ||
"value": 10 | ||
"value": 20 | ||
}, | ||
"let_it_snow_maxsize": { | ||
"label": "Max size", | ||
"info": "Max size of snowflake.", | ||
"type": "number", | ||
"value": 20 | ||
"value": 50 | ||
}, | ||
"let_it_snow_newon": { | ||
"label": "Snow frequency", | ||
"info": "Frequency in ms of appearing of new snowflake.", | ||
"type": "number", | ||
"value": "500" | ||
}, | ||
"let_it_snow_flakecolor": { | ||
"let_it_snow_flakecolor1": { | ||
"label": "Color", | ||
"info": "Color of snowflake.", | ||
"info": "Color of snowflake 1.", | ||
"type": "color", | ||
"value": "#FFFFFF" | ||
}, | ||
"let_it_snow_flakecolor2": { | ||
"label": "Color", | ||
"info": "Color of snowflake 2.", | ||
"type": "color", | ||
"value": "#B8B9BA" | ||
}, | ||
"let_it_snow_flakecolor3": { | ||
"label": "Color", | ||
"info": "Color of snowflake 3.", | ||
"type": "color", | ||
"value": "#636363" | ||
} | ||
} | ||
} |
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