Skip to content

Commit 96d0586

Browse files
committed
Merge pull request #20 from graywolf336/horizontal-percentage
Allow percentages in the horizontal offset
2 parents f64f891 + e05d751 commit 96d0586

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: scripts/angular-parallax.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ angular.module('angular-parallax', [
1111
},
1212
link: function($scope, elem, attrs) {
1313
var setPosition = function () {
14+
if(!$scope.parallaxHorizontalOffset) $scope.parallaxHorizontalOffset = '0';
1415
var calcValY = $window.pageYOffset * ($scope.parallaxRatio ? $scope.parallaxRatio : 1.1 );
1516
if (calcValY <= $window.innerHeight) {
1617
var topVal = (calcValY < $scope.parallaxVerticalOffset ? $scope.parallaxVerticalOffset : calcValY);
17-
elem.css('transform','translate(' + $scope.parallaxHorizontalOffset + 'px, ' +topVal+ 'px)');
18+
var hozVal = ($scope.parallaxHorizontalOffset.indexOf("%") === -1 ? $scope.parallaxHorizontalOffset + 'px' : $scope.parallaxHorizontalOffset);
19+
elem.css('transform', 'translate(' + hozVal + ', ' + topVal + 'px)');
1820
}
1921
};
2022

0 commit comments

Comments
 (0)