Skip to content

Instantly share code, notes, and snippets.

@hgo
Last active May 22, 2018 12:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgo/046346b6f9471cd761f8 to your computer and use it in GitHub Desktop.
Save hgo/046346b6f9471cd761f8 to your computer and use it in GitHub Desktop.
ionic on-slide - disable scroll
<ion-content class="has-header" direction="y" overflow-scroll="true">
<div class="list">
<div class="item">
<ion-slide-box on-slide-changed="slideHasChanged($index)" class="h300" show-pager="true">
<ion-slide ng-repeat="p in car.pictures" style="width:auto; !important" y-scroll-disable>
<div class="box">
<div style="height: 300px;
background: url('{{p}}') no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;">
</div>
<!--<img ng-src="{{p}}" style=""></img>-->
</div>
</ion-slide>
</ion-slide-box>
</div>
</div>
</ion-content>
.directive("yScrollDisable", function ($ionicScrollDelegate) {
return {
restrict: "A",
link: function (scope, element, attrs) {
function disable(){
$ionicScrollDelegate.freezeScroll(true);
}
function enable(){
$ionicScrollDelegate.freezeScroll(false);
}
element.on('mousedown',disable);
element.on('touchstart',disable);
element.on('touchend',enable);
element.on('mouseup',enable);
element.on('transitionend',enable);
element.on('resize',enable);
}
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment