Skip to content

Instantly share code, notes, and snippets.

@Zren
Last active April 29, 2017 18:26
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zren/beaafd64f395e23f4604 to your computer and use it in GitHub Desktop.
Save Zren/beaafd64f395e23f4604 to your computer and use it in GitHub Desktop.
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