Last active
September 25, 2017 11:12
-
-
Save hoodwink73/17eab7f983c2f44afbc79420e098fbb1 to your computer and use it in GitHub Desktop.
Scrollable Content
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| attributeBindings: ['index:data-item-index'] | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| items: [ | |
| 'John', | |
| 'Jane', | |
| 'Sally' | |
| ], | |
| scrollToCurrentItem () { | |
| const currentItemIndex = this.get('currentItem'); | |
| if (Ember.isNone(currentItemIndex) || currentItemIndex === -1 ) { | |
| return; | |
| } | |
| const itemToBeScrolledTo = this.$(`[data-item-index="${this.get('currentItem')}"]`); | |
| this.$('.tse-scroll-content').scrollTo(itemToBeScrolledTo, { | |
| duration: 400, | |
| interrupt: true, | |
| offset: { | |
| top: this.get('offset') | |
| } | |
| }) | |
| }, | |
| didRender () { | |
| this.scrollToCurrentItem(); | |
| }, | |
| didUpdateAttrs () { | |
| this.scrollToCurrentItem(); | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| currentItem: -1, | |
| actions: { | |
| selectItem (index) { | |
| this.set('currentItem', index) | |
| } | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
This file contains hidden or 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
| body { | |
| margin: 12px 16px; | |
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
| font-size: 12pt; | |
| } | |
| ul { | |
| list-style-type: none; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| li { | |
| text-align: center; | |
| font-size: 24px; | |
| line-height: 2; | |
| border-bottom: 1px solid darkslateblue; | |
| cursor: pointer; | |
| } | |
| li:hover { | |
| background-color: fuchsia; | |
| } | |
| .sidebar { | |
| position: fixed; | |
| background-color: darkorchid; | |
| width: 100px; | |
| top: 0; | |
| bottom: 0; | |
| right: 0; | |
| } | |
| .scrollable-container { | |
| position: fixed; | |
| top: 0; | |
| bottom: 0; | |
| left: 0; | |
| right: 100px; | |
| background-color: lavender; | |
| } | |
| .item { | |
| width: 300px; | |
| height: 400px; | |
| margin: 100px auto; | |
| border: 4px solid plum; | |
| border-radius: 8px; | |
| font-size: 96px; | |
| text-align: center; | |
| font-weight: bold; | |
| color: mediumorchid; | |
| } | |
This file contains hidden or 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
| { | |
| "version": "0.12.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "2.12.0", | |
| "ember-template-compiler": "2.12.0", | |
| "ember-testing": "2.12.0", | |
| "jquery.scrollTo": "https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.2/jquery.scrollTo.min.js" | |
| }, | |
| "addons": { | |
| "ember-data": "2.12.1", | |
| "ember-scrollable": "*" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment