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

How to use IronScrollTargetBehavior with ES6? #37

Open
kokoron opened this issue Nov 25, 2017 · 1 comment
Open

How to use IronScrollTargetBehavior with ES6? #37

kokoron opened this issue Nov 25, 2017 · 1 comment

Comments

@kokoron
Copy link

kokoron commented Nov 25, 2017

_scrollHandler() is not work.
How I get scroll offset?

<link rel="import" href="../../../bower_components/iron-scroll-target-behavior/iron-scroll-target-behavior.html">
class ContainerView extends Polymer.Element {
            static get is() { return 'container-view'; }
            static get properties() {
                return {
                };
            }
            static get behaviors() { return [Polymer.IronScrollTargetBehavior]; }
            _scrollHandler() {
                console.log(this._scrollTop()); // <= not work
            }
        }
@lukawski
Copy link

Importing this behavior is not enough. You have to include it into your class declaration.

Change this line

class ContainerView extends Polymer.Element {

into

class ContainerView extends Polymer.mixinBehaviors([
		Polymer.IronScrollTargetBehavior
], Polymer.Element) {

Also, this line this._scrollTop() should be changed into this._scrollTop. Since _scrollTop property is a getter, not a regular method, you can't invoke it.
Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get

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

No branches or pull requests

2 participants