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

Custom scroller #85

Closed
wants to merge 1 commit into from
Closed

Custom scroller #85

wants to merge 1 commit into from

Conversation

blasten
Copy link
Contributor

@blasten blasten commented Aug 29, 2015

One of the requested feature:

  • External scrollTarget (it currently works for paper-scroll-header-panel)
    • Listen & measure on parent div
    • Measure offsetTop & take into account

Also, I'm using the document scroll in the new layout elements: https://github.com/PolymerLabs/app-layout.

A few use cases:

cc @frankiefu

@kevinpschaaf
Copy link
Contributor

Generally speaking, concept is fine. General points:

It would be good to get team consensus on how elements that need references to user-supplied peer or parent nodes should expose API's to get the node reference from the user.

After talking to @cdata, it seems there are a few existing techniques used:

  • accept JS reference (user must poke using imperative code after creation)
  • accept ID reference (requires finding host and then selecting id in host's scope, not horrible but finding host is somewhat shaky ground)
  • accept selector (same as ID, requires finding host)
  • find node in parent by convention (e.g. parentNode.scroller; requires tight coupling, not awesome)
  • accept hard-coded strings, i.e. window (doesn't scale to arbitrary nodes)
  • auto-find element in tree based on style, e.g. parent with overflow (requires climbing composed tree, which requires different slightly skeezy techniques depending on native vs. shady DOM)

Judging by the current code, the scroller property currently accepts:

  • "window" (hard-coded string)
  • a JS reference to a node (poked imperatively after creation)
  • will automatically take parentNode.scroller if it exists at attached time, or
  • will fall back to this (the list itself)

I would like to discuss this a bit before we lock in an API here.

I'll make other comments inline.

}

if (oldScroller && oldScroller.addEventListener) {
oldScroller.addEventListener('scroll', this._scrollListener);
Copy link
Contributor

Choose a reason for hiding this comment

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

should be removeEventListener?

@blasten
Copy link
Contributor Author

blasten commented Sep 25, 2015

@kevinpschaaf sounds goo :) I'd love to discuss this in detail with @cdata. BTW: here's the code for custom scroll target as a behavior: https://github.com/PolymerLabs/app-layout/blob/master/scroll-behaviors/custom-scroller-behavior.html

@kevinpschaaf
Copy link
Contributor

Yeah, I also want to get some core team input on the general topic as well.

@cdata
Copy link
Contributor

cdata commented Oct 1, 2015

@kevinpschaaf @blasten Regarding consensus on how to declare element siblings, cousins or ancestors for a given element...

Right now we have a few other elements that need to do similar things, and all of them are different implementations:

  1. iron-label https://github.com/polymerelements/iron-label
  2. paper-badge https://github.com/PolymerElements/paper-badge
  3. paper-tooltip https://github.com/PolymerElements/paper-tooltip
  4. iron-fit-behavior https://github.com/PolymerElements/iron-fit-behavior/blob/master/iron-fit-behavior.html#L38-L49
  5. iron-dropdown https://github.com/PolymerElements/iron-dropdown/blob/master/iron-dropdown.html#L123-L130
  6. paper-ripple https://github.com/polymerelements/paper-ripple

There are probably other examples. All examples fundamentally expect the same thing: a property that maps to an element reference, and in all cases the element is not expected to be a member of the host's Shadow tree. The following are sources of variation in implementations:

  • The semantics governing which elements are valid values tend to differ.
  • The name of the host attribute that refers to another element relates to the use case or implementation of the host.

It kind of seems to me that a primitive mechanism in Polymer core (perhaps something like special support for a property with type: Element) would be really helpful to have in this case.

At any rate, it would be really nice to be able to standardize this somehow. There seems to be a lot of overlap (granted not 100%) between implementations.

@blasten
Copy link
Contributor Author

blasten commented Oct 1, 2015

@cdata good. I like the idea of the Element type a lot. What do you think about this example: https://github.com/PolymerLabs/app-layout/blob/master/scroll-behaviors/custom-scroller-behavior.html

CustomScrollerBehaviorcurrently uses Object similarly to iron-dropdown, but it also accept the string window. In the case that we end up with Element, this behavior could use html instead of window to point to the document element.

@blasten
Copy link
Contributor Author

blasten commented Jan 12, 2016

I'm closing this PR in favor of Polymer.IronScrollTargetBehavior

@blasten blasten closed this Jan 12, 2016
@blasten blasten deleted the custom-scroller branch January 12, 2016 20:21
@blasten blasten restored the custom-scroller branch January 12, 2016 22:19
@blasten blasten deleted the custom-scroller branch February 23, 2016 18:19
@keanulee keanulee restored the custom-scroller branch February 23, 2016 18:54
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.

None yet

4 participants