-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Brightspace/US76170
US76170 - Add d2l-sticky-element for scroll buttons
- Loading branch information
Showing
9 changed files
with
377 additions
and
301 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<link rel="import" href="../polymer/polymer.html"> | ||
|
||
<!-- | ||
Copied with modifications and fixes from https://github.com/seaneking/sticky-element/blob/master/sticky-element.html | ||
--> | ||
|
||
<script src="../Stickyfill/dist/stickyfill.min.js"></script> | ||
<dom-module id="d2l-sticky-element"> | ||
<template> | ||
<style> | ||
:host { | ||
position: -webkit-sticky; | ||
position: sticky; | ||
top: 0; | ||
z-index: 1; | ||
} | ||
</style> | ||
<content></content> | ||
</template> | ||
<script> | ||
/* global Stickyfill */ | ||
Polymer({ | ||
is: 'd2l-sticky-element', | ||
properties: { | ||
disabled: { | ||
type: Boolean, | ||
observer: '_disabledChanged' | ||
} | ||
}, | ||
_updateSticky: function(sticky) { | ||
if (sticky) { | ||
Stickyfill.add(this); | ||
} else { | ||
Stickyfill.remove(this); | ||
} | ||
Stickyfill.rebuild(); | ||
}, | ||
_disabledChanged: function(disabled) { | ||
/** | ||
* updateSticky requires the component to be attached to the DOM | ||
* in order to work. If the component is not attached, the attached | ||
* method will handle initialization | ||
*/ | ||
if (this.isAttached) { | ||
this.async(this._updateSticky.bind(this, !disabled), 1); | ||
} | ||
}, | ||
attached: function() { | ||
if (!this.disabled) { | ||
// Async is used to ensure the call occurs after paint | ||
this.async(this._updateSticky.bind(this, true), 1); | ||
} | ||
} | ||
}); | ||
</script> | ||
</dom-module> |
Oops, something went wrong.