Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove app-scroll-position #417

Merged
merged 6 commits into from
Mar 13, 2017
Merged

Conversation

blasten
Copy link
Contributor

@blasten blasten commented Mar 1, 2017

No description provided.

Copy link
Contributor

@frankiefu frankiefu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this too:

'../app-scroll-position/test/index.html',

@@ -131,9 +130,6 @@
</app-header-layout>
</app-drawer>

<app-scroll-position
selected="[[_pageData.page]]"
reset="[[_isDetailPage(_pageData.page)]]"></app-scroll-position>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some JS code to save the scroll position so if you navigate back to the list page you are at the previous scroll position. This code will serve as a sample for users for replacing app-scroll-position element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -29,7 +29,6 @@
<link rel="import" href="../bower_components/app-layout/app-header/app-header.html">
<link rel="import" href="../bower_components/app-layout/app-header-layout/app-header-layout.html">
<link rel="import" href="../bower_components/app-layout/app-toolbar/app-toolbar.html">
<link rel="import" href="../bower_components/app-layout/app-scroll-position/app-scroll-position.html">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this old <app-scrollpos-control> too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@blasten
Copy link
Contributor Author

blasten commented Mar 2, 2017

PTAL

@@ -118,21 +126,28 @@

<!-- nav menu -->
<paper-listbox
selected="{{_pageData.page}}"
selected="[[_pageData.page]]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why there needs to be a separate _selectedPage property, but why does this need to change to one-way bound _pageData.page with <a> links for navigation? This is an issue if a user clicks on the <paper-item> outside of the <a> (where the paper-item gets selected, but the link isn't clicked).

Copy link
Contributor Author

@blasten blasten Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a bug in Polymer 2.0 that causes a notification to be missed. I will file the bug as soon as I can.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment with a TODO that we should change this back once the issue in Polymer2 is fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a tracking issue in polymer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will file the bug asap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done tracking issue is: Polymer/polymer#4405

}
this._selectedPage = pageData.page;
if (map[pageData.page] != null) {
window.scrollTo(0, map[pageData.page]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Polymer.AppLayout.scroll({ top: scrollTop, behavior: 'silent' });

if (map[subroute.prefix] != null) {
window.scrollTo(0, map[subroute.prefix]);
} else if (this.isAttached) {
window.scrollTo(0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Polymer.AppLayout.scroll({ top: scrollTop, behavior: 'silent' });

@MeTaNoV
Copy link

MeTaNoV commented Mar 7, 2017

interesting... any other way to have a more flexible implementation?

@frankiefu
Copy link
Contributor

@MeTaNoV We feel that there isn't a guaranteed way to make this element works reliably because to save the current scroll position it needs to do that before the page visibility changes. Ideally it should be handled inside iron-pages. We will look into providing a better solution in the future. For now you will need to save/restore scroll position in code. An example:

_pageDataChanged: function(pageData, oldPageData) {
var map = this._scrollPositionMap;
if (oldPageData != null && oldPageData.page != null) {
map[oldPageData.page] = window.pageYOffset;
}
this._selectedPage = pageData.page;
if (map[pageData.page] != null) {
Polymer.AppLayout.scroll({ top: map[pageData.page], behavior: 'silent' });
} else if (this.isAttached) {
Polymer.AppLayout.scroll({ top: 0, behavior: 'silent' });
}
}

@frankiefu
Copy link
Contributor

@blasten Just need to add the comment and otherwise LGTM

@MeTaNoV
Copy link

MeTaNoV commented Mar 7, 2017

thx @frankiefu for your answer, I agree that it should be handled in any since there is not only iron-pages but others (including my own iron-swipeable-pages) that need to handle this. Do you think that a behaviour could be extracted to be used by the different elements or by extending a base iron-pages we could reuse the implementation? I am not yet familiar with 2.0 so I cannot tell directly...
@TimvdLippe might be probably interested also!

@frankiefu
Copy link
Contributor

@MeTaNoV Yeah, a behavior makes a lot of sense. Good suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants