Permalink
Browse files

Formatting

  • Loading branch information...
jatitoam committed Oct 31, 2012
1 parent 9ab4e42 commit c6c0479a3e9df098cb70eb46878868e44db27700
Showing with 21 additions and 22 deletions.
  1. +17 −18 source/jarallax_animation.js
  2. +4 −4 source/jarallax_tools.js
@@ -42,31 +42,30 @@ JarallaxAnimation.prototype.activate = function (progress) {
for(var i in this.startValues) {
if (i !== 'progress' && i !== 'style' && i !== 'event') {
if (undefined !== this.endValues[i] && i !== 'display' && i !== 'backgroundImage') {
-
- var astart = JarallaxTools.getValues(this.startValues[i]+'');
- var aend = JarallaxTools.getValues(this.endValues[i]+'');
-
- var fullresult = '';
- for (var j=0; j<astart.length; j++) {
+
+ var astart = JarallaxTools.getValues(this.startValues[i]+'');
+ var aend = JarallaxTools.getValues(this.endValues[i]+'');
+
+ var fullresult = '';
+ for (var j=0; j<astart.length; j++) {
var startValue = astart[j].value;
var endValue = aend[j].value;
-
+
var duration = end - start;
var currentTime = (progress-start);
var changeInValue = endValue - startValue;
- var result = Jarallax.EASING[style.easing](currentTime,
- startValue , changeInValue, duration, style.power);
+ var result = Jarallax.EASING[style.easing](currentTime, startValue , changeInValue, duration, style.power);
+
+ if(astart[j].unit == 'px'){
+ result = parseInt(result, 10);
+ }
- if(astart[j].unit == 'px'){
- result = parseInt(result, 10);
- }
+ if(astart[j].unit !== '.'){
+ result+= astart[j].unit;
+ }
- if(astart[j].unit !== '.'){
- result+= astart[j].unit;
- }
-
- fullresult += result + ' ';
- }
+ fullresult += result + ' ';
+ }
jQuery(this.selector).css(i,fullresult);
} else {
jQuery(this.selector).css(i,this.startValues[i]);
View
@@ -59,7 +59,7 @@ JarallaxTools.calculateNewValue = function (modifier, original) {
} else {
result = modifier;
}
-
+
if(original.indexOf){
if(original.indexOf('%') > 0){
return result + '%';
@@ -69,10 +69,10 @@ JarallaxTools.calculateNewValue = function (modifier, original) {
};
JarallaxTools.getValues = function (string) {
- string = string.replace(/ /g,' ').replace(/ /g,' ');
+ string = string.replace(' ',' ').replace(' ',' ');
var v = string.split(' ');
- var f = new Array();
+ var f = [];
for (var i=0; i<v.length; i++) {
var u = {};
u.unit = JarallaxTools.getUnits(v[i]).replace('-','');
@@ -81,7 +81,7 @@ JarallaxTools.getValues = function (string) {
}
return f;
-}
+};
JarallaxTools.getUnits = function (string) {
return string.replace(/\d+/g, '');

0 comments on commit c6c0479

Please sign in to comment.