Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ionic Scroll onMouseWheel
app.directive 'mouseWheelScroll', ($timeout) ->
return {
restrict: 'A'
# require: '^$ionicScroll'
link: ($scope, $element, $attrs) ->
scrollCtrl = $element.controller('$ionicScroll')
console.log scrollCtrl
unless scrollCtrl
return console.error('mouseWheelScroll must be attached to a $ionicScroll controller.')
onMouseWheel = (e) ->
scrollCtrl.scrollBy 0, -e.wheelDeltaY, false
# halfHeight = scrollCtrl.element.clientHeight / 2
# deltaY = if e.wheelDeltaY > 0 then 1 else -1
# deltaY = halfHeight * deltaY
# scrollCtrl.scrollBy 0, -deltaY, false
scrollCtrl.element.addEventListener 'wheel', onMouseWheel
}
<ion-content mouse-wheel-scroll>
<ion-list>
<ion-item
class=""
collection-repeat="chapter in chapters"
collection-item-width="'100%'"
collection-item-height="50"
style="width:100%;height:50px;"
ng-href="{{comic && chapter && urlFor.Reader(providerKey, comic, chapter)}}"
>
{{chapter.title}}
<span class="item-note"><time>{{chapter.updated | date:'short'}}</time> – #{{chapter.index}}</span>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment