Last active
August 23, 2016 16:26
-
-
Save alexBaizeau/9ad155ebe5834b8c8cfec0b2e0f12a8d to your computer and use it in GitHub Desktop.
Scrol Scroll
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({ | |
classNames: ['scrolly-parent'], | |
didInsertElement() { | |
let component = this; | |
this.$().on('DOMMouseScroll mousewheel', (ev) => { | |
let $this = component.$(), | |
scrollTop = component.element.scrollTop, | |
scrollHeight = component.element.scrollHeight, | |
height = $this.innerHeight(), | |
delta = ev.originalEvent.wheelDelta, | |
up = delta > 0; | |
let prevent = function() { | |
ev.stopPropagation(); | |
ev.preventDefault(); | |
ev.returnValue = false; | |
return false; | |
} | |
// debugger | |
if (!up && -delta > scrollHeight - height - scrollTop) { | |
// Scrolling down, but this will take us past the bottom. | |
$this.scrollTop(scrollHeight); | |
return prevent(); | |
} else if (up && delta > scrollTop) { | |
// Scrolling up, but this will take us past the top. | |
$this.scrollTop(0); | |
return prevent(); | |
} | |
}); | |
} | |
}); |
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; | |
} | |
.scrolly-parent { | |
overflow-y: scroll; | |
height: 200px; | |
width: 300px; | |
background: pink; | |
padding: 0 0 0 10px; | |
} |
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.10.4", | |
"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.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment