Skip to content

Commit

Permalink
Make adjustedViewportHeight public
Browse files Browse the repository at this point in the history
It's accessed from outside the class, meaning it's public.
  • Loading branch information
jridgewell committed Apr 23, 2018
1 parent 77bf28c commit 4cfd087
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions extensions/amp-fx-collection/0.1/providers/amp-fx-presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export const Presets = {
},
update(entry) {
const fxElement = this;
dev().assert(fxElement.adjustedViewportHeight_);
dev().assert(fxElement.adjustedViewportHeight);
const top = entry.positionRect ? entry.positionRect.top : null;
// outside viewport
if (!top || top > fxElement.adjustedViewportHeight_) {
if (!top || top > fxElement.adjustedViewportHeight) {
return;
}

Expand All @@ -47,7 +47,7 @@ export const Presets = {
const adjustedFactor = -(parseFloat(fxElement.getFactor()) - 1);
// Offset is how much extra to move the element which is position within
// viewport times adjusted factor.
const offset = (fxElement.adjustedViewportHeight_ - top) * adjustedFactor;
const offset = (fxElement.adjustedViewportHeight - top) * adjustedFactor;
fxElement.setOffset(offset);

if (fxElement.isMutateScheduled()) {
Expand Down Expand Up @@ -82,11 +82,11 @@ export const Presets = {
},
update(entry) {
const fxElement = this;
dev().assert(fxElement.adjustedViewportHeight_);
dev().assert(fxElement.adjustedViewportHeight);
const top = entry.positionRect ? entry.positionRect.top : null;
// Outside viewport
if (!top || top > (1 - fxElement.getMarginStart()) *
fxElement.adjustedViewportHeight_) {
fxElement.adjustedViewportHeight) {
return;
}

Expand Down Expand Up @@ -132,11 +132,11 @@ export const Presets = {
},
update(entry) {
const fxElement = this;
dev().assert(fxElement.adjustedViewportHeight_);
dev().assert(fxElement.adjustedViewportHeight);
const top = entry.positionRect ? entry.positionRect.top : null;
// Outside viewport or margins
if (!top || (top > (1 - fxElement.getMarginStart()) *
fxElement.adjustedViewportHeight_)) {
fxElement.adjustedViewportHeight)) {
return;
}

Expand All @@ -152,9 +152,9 @@ export const Presets = {
const marginDelta = fxElement.getMarginEnd() - fxElement.getMarginStart();
// Offset is how much extra to move the element which is position within
// viewport times adjusted factor.
const offset = 1 * (fxElement.adjustedViewportHeight_ - top -
(fxElement.getMarginStart() * fxElement.adjustedViewportHeight_)) /
(marginDelta * fxElement.adjustedViewportHeight_);
const offset = 1 * (fxElement.adjustedViewportHeight - top -
(fxElement.getMarginStart() * fxElement.adjustedViewportHeight)) /
(marginDelta * fxElement.adjustedViewportHeight);
fxElement.setOffset(offset);

if (fxElement.isMutateScheduled()) {
Expand Down
8 changes: 4 additions & 4 deletions extensions/amp-fx-collection/0.1/providers/fx-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export class FxElement {
/** @const @private {!../../../../src/service/resources-impl.Resources} */
this.resources_ = resources;

/** @private {?number} */
this.adjustedViewportHeight_ = null;
/** @type {?number} */
this.adjustedViewportHeight = null;

/** @private @const {!Element} */
this.element_ = element;
Expand Down Expand Up @@ -153,7 +153,7 @@ export class FxElement {
this.hasRepeat_ = element.hasAttribute('data-repeat');

this.getAdjustedViewportHeight_().then(adjustedViewportHeight => {
this.adjustedViewportHeight_ = adjustedViewportHeight;
this.adjustedViewportHeight = adjustedViewportHeight;

// start observing position of the element.
this.observePositionChanges_();
Expand All @@ -170,7 +170,7 @@ export class FxElement {

this.viewport_.onResize(() => {
this.getAdjustedViewportHeight_().then(adjustedViewportHeight => {
this.adjustedViewportHeight_ = adjustedViewportHeight;
this.adjustedViewportHeight = adjustedViewportHeight;
});
});
}
Expand Down

0 comments on commit 4cfd087

Please sign in to comment.