Created
May 16, 2018 15:56
-
-
Save majido/2e95c5bece528faffb9394914bf2dde5 to your computer and use it in GitHub Desktop.
Implementing a declarative scroll propagation control on top of scroll customization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OverflowPropagationElement extends HTMLElement { | |
createdCallback() { | |
// See design doc for details of these experimental APIs: https://docs.google.com/document/d/1VnvAqeWFG9JFZfgG5evBqrLGDZYRE5w6G5jEDORekPY/edit | |
this.distributeScrollIntent = function(scrollIntent) { | |
if (scrollIntent.deltaY <= 0) { | |
if (this.getComputedValue('overflow-propagation-up') == 'normal') { | |
// let children scroll first and then we scroll if any delta remaining | |
scrollIntent.distributeToScrollChainDescendant(); | |
this.applyScrollIntent(scrollState); | |
} else { | |
// we scroll first and then let children scroll if any delta remaining | |
this.applyScrollIntent(scrollState); | |
scrollIntent.distributeToScrollChainDescendant(); | |
} | |
} | |
// same for other directions | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment