Skip to content

Commit

Permalink
🐛 amp-next-page fix interaction with styles (#25959)
Browse files Browse the repository at this point in the history
* Use a standalone measuring element instead of relying on the separator

* Prevent styling
  • Loading branch information
wassgha authored Dec 10, 2019
1 parent 148182f commit 67d1415
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion extensions/amp-next-page/0.1/next-page-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ export class NextPageService {
return amp;
}

/**
* Creates an invisible element used to measure the position of the documents
* @return {!Element}
*/
createMeasurer_() {
const measurer = this.win_.document.createElement('div');
measurer.classList.add('i-amphtml-next-page-measurer');
return measurer;
}

/**
* Creates a default hairline separator element to go between two documents.
* @return {!Element}
Expand All @@ -262,6 +272,9 @@ export class NextPageService {

const container = this.win_.document.createElement('div');

const measurer = this.createMeasurer_();
container.appendChild(measurer);

const separator = this.separator_.cloneNode(true);
separator.removeAttribute('separator');
container.appendChild(separator);
Expand All @@ -276,7 +289,7 @@ export class NextPageService {
const page = this.nextArticle_;
this.appendPageHandler_(container).then(() => {
this.positionObserver_.observe(
separator,
measurer,
PositionObserverFidelity.LOW,
position => this.positionUpdate_(page, position)
);
Expand Down

0 comments on commit 67d1415

Please sign in to comment.