-
Notifications
You must be signed in to change notification settings - Fork 54
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 #4 from TrySound/master
scope and dist
- Loading branch information
Showing
8 changed files
with
234 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*! Ripple.js v1.2.1 | ||
* The MIT License (MIT) | ||
* Copyright (c) 2014 Jacob Kelley */ | ||
|
||
.has-ripple { | ||
position: relative; | ||
overflow: hidden; | ||
-webkit-transform: translate3d(0,0,0); | ||
-o-transform: translate3d(0,0,0); | ||
transform: translate3d(0,0,0); | ||
} | ||
.ripple { | ||
display: block; | ||
position: absolute; | ||
pointer-events: none; | ||
border-radius: 50%; | ||
|
||
-webkit-transform: scale(0); | ||
-o-transform: scale(0); | ||
transform: scale(0); | ||
|
||
background: #fff; | ||
opacity: 1; | ||
} | ||
.ripple-animate { | ||
-webkit-animation: ripple; | ||
-o-animation: ripple; | ||
animation: ripple; | ||
} | ||
@-webkit-keyframes ripple { | ||
100% { | ||
opacity: 0; | ||
-webkit-transform: scale(2); | ||
transform: scale(2); | ||
} | ||
} | ||
@-o-keyframes ripple { | ||
100% { | ||
opacity: 0; | ||
-o-transform: scale(2); | ||
transform: scale(2); | ||
} | ||
} | ||
@keyframes ripple { | ||
100% { | ||
opacity: 0; | ||
transform: scale(2); | ||
} | ||
} |
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,139 @@ | ||
/*! Ripple.js v1.2.1 | ||
* The MIT License (MIT) | ||
* Copyright (c) 2014 Jacob Kelley */ | ||
|
||
;(function($, document, Math){ | ||
$.ripple = function(selector, options) { | ||
|
||
var self = this; | ||
|
||
var _log = self.log = function() { | ||
if(self.defaults.debug && console && console.log) { | ||
console.log.apply(console, arguments); | ||
} | ||
}; | ||
|
||
self.selector = selector; | ||
self.defaults = { | ||
debug: false, | ||
on: 'mousedown', | ||
|
||
opacity: 0.4, | ||
color: "auto", | ||
multi: false, | ||
|
||
duration: 0.7, | ||
rate: function(pxPerSecond) { | ||
return pxPerSecond; | ||
}, | ||
|
||
easing: 'linear' | ||
}; | ||
|
||
self.defaults = $.extend({}, self.defaults, options); | ||
|
||
var Trigger = function(e) { | ||
|
||
var $this = $(this); | ||
var $ripple; | ||
var settings; | ||
|
||
$this.addClass('has-ripple'); | ||
|
||
// This instances settings | ||
settings = $.extend({}, self.defaults, $this.data()); | ||
|
||
// Create the ripple element | ||
if ( settings.multi || (!settings.multi && $this.find(".ripple").length === 0) ) { | ||
$ripple = $("<span></span>").addClass("ripple"); | ||
$ripple.appendTo($this); | ||
|
||
_log('Create: Ripple'); | ||
|
||
// Set ripple size | ||
if (!$ripple.height() && !$ripple.width()) { | ||
var size = Math.max($this.outerWidth(), $this.outerHeight()); | ||
$ripple.css({ | ||
height: size, | ||
width: size | ||
}); | ||
_log('Set: Ripple size'); | ||
} | ||
|
||
// Give the user the ability to change the rate of the animation | ||
// based on element width | ||
if(settings.rate && typeof settings.rate == "function") { | ||
|
||
// rate = pixels per second | ||
var rate = Math.round( $ripple.width() / settings.duration ); | ||
|
||
// new amount of pixels per second | ||
var filteredRate = settings.rate(rate); | ||
|
||
// Determine the new duration for the animation | ||
var newDuration = ( $ripple.width() / filteredRate); | ||
|
||
// Set the new duration if it has not changed | ||
if(settings.duration.toFixed(2) !== newDuration.toFixed(2)) { | ||
_log('Update: Ripple Duration', { | ||
from: settings.duration, | ||
to: newDuration | ||
}); | ||
settings.duration = newDuration; | ||
} | ||
} | ||
|
||
// Set the color and opacity | ||
var color = (settings.color == "auto") ? $this.css('color') : settings.color; | ||
var css = { | ||
animationDuration: (settings.duration).toString() + 's', | ||
animationTimingFunction: settings.easing, | ||
background: color, | ||
opacity: settings.opacity | ||
}; | ||
|
||
_log('Set: Ripple CSS', css); | ||
$ripple.css(css); | ||
} | ||
|
||
// Ensure we always have the ripple element | ||
if(!settings.multi) { | ||
_log('Set: Ripple Element'); | ||
$ripple = $this.find(".ripple"); | ||
} | ||
|
||
// Kill animation | ||
_log('Destroy: Ripple Animation'); | ||
$ripple.removeClass("ripple-animate"); | ||
|
||
|
||
// Retrieve coordinates | ||
var x = e.pageX - $this.offset().left - $ripple.width() / 2; | ||
var y = e.pageY - $this.offset().top - $ripple.height() / 2; | ||
|
||
/** | ||
* We want to delete the ripple elements if we allow multiple so we dont sacrifice any page | ||
* performance. We don't do this on single ripples because once it has rendered, we only | ||
* need to trigger paints thereafter. | ||
*/ | ||
if(settings.multi) { | ||
_log('Set: Ripple animationend event'); | ||
$ripple.one('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function() { | ||
_log('Note: Ripple animation ended'); | ||
_log('Destroy: Ripple'); | ||
$(this).remove(); | ||
}); | ||
} | ||
|
||
// Set position and animate | ||
_log('Set: Ripple location'); | ||
_log('Set: Ripple animation'); | ||
$ripple.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}).addClass("ripple-animate"); | ||
}; | ||
|
||
$(document).on(self.defaults.on, self.selector, Trigger); | ||
}; | ||
})(jQuery, document, Math); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
{ | ||
"name": "Ripple.js", | ||
"author": "Jacob Kelley", | ||
"version": "1.2.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jakiestfu/Ripple.js.git" | ||
}, | ||
"scripts": { | ||
"bower": "./node_modules/bower/bin/bower install", | ||
"build": "./node_modules/grunt-cli/bin/grunt", | ||
"build-watch": "./node_modules/grunt-cli/bin/grunt develop" | ||
}, | ||
"devDependencies": { | ||
"bower": "*", | ||
"grunt": "~0.4.1", | ||
"grunt-cli": "~0.1.9", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"grunt-contrib-uglify": "0.2.5", | ||
"grunt-contrib-jshint": "0.8.0", | ||
"grunt-contrib-cssmin": "0.10.0" | ||
} | ||
"name": "Ripple.js", | ||
"author": "Jacob Kelley", | ||
"version": "1.2.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jakiestfu/Ripple.js.git" | ||
}, | ||
"scripts": { | ||
"bower": "./node_modules/bower/bin/bower install", | ||
"build": "./node_modules/grunt-cli/bin/grunt", | ||
"build-watch": "./node_modules/grunt-cli/bin/grunt develop" | ||
}, | ||
"devDependencies": { | ||
"bower": "*", | ||
"grunt": "~0.4.1", | ||
"grunt-cli": "~0.1.9", | ||
"grunt-contrib-concat": "^0.5.0", | ||
"grunt-contrib-cssmin": "0.10.0", | ||
"grunt-contrib-jshint": "0.8.0", | ||
"grunt-contrib-uglify": "0.2.5", | ||
"grunt-contrib-watch": "~0.5.3" | ||
} | ||
} |
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