diff --git a/bower.json b/bower.json index f40b1b0..2c9cd91 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-parallax", - "version": "0.0.1", + "version": "0.0.2", "homepage": "https://github.com/brettdonohoo/angular-parallax", "authors": [ "Brett Donohoo " diff --git a/index.html b/index.html index 48589ed..f0c0f54 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@

Angular Parallax

Nature
-
Food
+
Food
Animals
Cats
diff --git a/scripts/angular-parallax.js b/scripts/angular-parallax.js index 6ec39e8..a666b04 100644 --- a/scripts/angular-parallax.js +++ b/scripts/angular-parallax.js @@ -34,10 +34,15 @@ angular.module('angular-parallax', [ template: '
', scope: { parallaxRatio: '@', + parallaxBackgroundPosition: '@' }, link: function($scope, elem, attrs) { var setPosition = function () { var calcValY = (elem.prop('offsetTop') - $window.pageYOffset) * ($scope.parallaxRatio ? $scope.parallaxRatio : 1.1 ); + if($scope.parallaxPosition === 'center') { + calcValY -= elem[0].offsetHeight / 2; + } + // horizontal positioning elem.css('background-position', "50% " + calcValY + "px"); };