Skip to content

Commit fd35d5a

Browse files
committed
Using scope for consistency within directives. A little bit of cleanup.
1 parent b718aa5 commit fd35d5a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div ng-controller="ParallaxExampleCtrl">
77
<h1 parallax parallax-ratio="1.22" parallax-vertical-offset="10" parallax-horizontal-offset="600" class="parallax">Angular Parallax</h1>
88
<div parallax-background class="photo nature" parallax-ratio="0.5"><span style="font-size:1em;">Nature</span></div>
9-
<div parallax-background class="photo food" parallax-ratio="0.8"><span style="font-size:4em;">Food</span></div>
9+
<div parallax-background class="photo food" parallax-ratio="0.8" parallax-vertical-offset="100"><span style="font-size:4em;">Food</span></div>
1010
<div parallax-background class="photo animals" parallax-ratio="0.7">Animals</div>
1111
<div parallax-background class="photo cats" parallax-ratio="1">Cats</div>
1212
<img parallax parallax-ratio="1.88" parallax-vertical-offset="100" parallax-horizontal-offset="40" class="parallax" src="images/muther.jpg" />

Diff for: scripts/angular-parallax.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ angular.module('angular-parallax', [
3333
template: '<div ng-transclude></div>',
3434
scope: {
3535
parallaxRatio: '@',
36+
parallaxVerticalOffset: '@',
3637
},
3738
link: function($scope, elem, attrs) {
3839
var setPosition = function () {
39-
var calcValY = (elem.prop('offsetTop') - $window.pageYOffset) * ($scope.parallaxRatio ? $scope.parallaxRatio : 1.1 ) - ( attrs.parallaxVerticalOffset || 0);
40+
var calcValY = (elem.prop('offsetTop') - $window.pageYOffset) * ($scope.parallaxRatio ? $scope.parallaxRatio : 1.1) - ($scope.parallaxVerticalOffset || 0);
4041
// horizontal positioning
4142
elem.css('background-position', "50% " + calcValY + "px");
4243
};

0 commit comments

Comments
 (0)