Skip to content

Commit

Permalink
Merge pull request #2 from Civetdelapin/master
Browse files Browse the repository at this point in the history
added 'parallaxPivot' variable
  • Loading branch information
TyrantWave authored May 7, 2019
2 parents 716ef55 + 6687a5f commit 3a619ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class ParallaxScrollDirective implements OnInit {
@Input() private cssUnit = 'px';
@Input() private scrollerId: string;
@Input() private parallaxElement: HTMLElement;
@Input() private parallaxPivot = '50%';

private cssProperty = 'backgroundPosition';
private scrollElement: any;
Expand Down Expand Up @@ -86,9 +87,9 @@ export class ParallaxScrollDirective implements OnInit {

// Get output based on axis
if (this.axis === 'X') {
result = 'calc(50% + ' + scrollPosition + this.cssUnit + ') center';
result = 'calc(' + this.parallaxPivot + ' + ' + scrollPosition + this.cssUnit + ') center';
} else {
result = 'center calc(50% + ' + scrollPosition + this.cssUnit + ')';
result = 'center calc(' + this.parallaxPivot + ' + ' + scrollPosition + this.cssUnit + ')';
}

this.parallaxElement.style[this.cssProperty as any] = result;
Expand Down
2 changes: 2 additions & 0 deletions projects/ng2-parallaxscroll/src/lib/ng2-parallaxscroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ export interface IParallaxScrollConfig {
// what element moves when you scroll, defaults to the body
parallaxElement?: HTMLElement;

// parallax pivot of the axis - default to '50%'
parallaxPivot?: string;
}

0 comments on commit 3a619ae

Please sign in to comment.