Ion-slide-box disable-scroll doesn't work


#1

When using ion-slide-box, the disable-scroll option does not work. Looking at the source code, I can see the following lines of code:

if (!(e.touches.length > 1 || e.scale && 1 !== e.scale)) {
                            t.disableScroll && e.preventDefault();
                            var i = e.touches[0];
                            x = { x: i.pageX - D.x, y: i.pageY - D.y }, "undefined" == typeof b && (b = !!(b || Math.abs(x.x) < Math.abs(x.y))), b || (e.preventDefault(), u(), t.continuous ? (a(r(E - 1), x.x + p[r(E - 1)], 0), a(E, x.x + p[E], 0), a(r(E + 1), x.x + p[r(E + 1)], 0)) : (x.x = x.x / (!E && x.x > 0 || E == g.length - 1 && x.x < 0 ? Math.abs(x.x) / m + 1 : 1), a(E - 1, x.x + p[E - 1], 0), a(E, x.x + p[E], 0), a(E + 1, x.x + p[E + 1], 0)))
                        }

The line “t.disableScroll && e.preventDefault();” does absolutely nothing except prevent default. Shouldn’t it look a little more like this:

if (!(e.touches.length > 1 || e.scale && 1 !== e.scale) && !t.disableScroll) {
...
}

Also, if disableScroll changes value then it should be updated. Should there be a .$watch("disableScroll", function (e) {...} or something similar?

Anyone got any ideas on how to fix this temporarily or why this isn’t working for me?


#2

How about this for a solution…

Add disableScroll and enableScroll to the ionicSlideBoxDelegate:

.service("$ionicSlideBoxDelegate",e(["update","slide","previous","next","stop","currentIndex","slidesCount","disableScroll","enableScroll"]))

Add two new functions called disableScroll and enableScroll:

this.update=function(){setTimeout(e)},this.setup=function(){e()},this.slide=function(t,e){u(),o(t,e)},this.prev=this.previous=function(){u(),i()},this.next=function(){u(),n()},this.stop=function(){u()},this.currentIndex=function(){return E},this.disableScroll=function(){t.disableScroll=true},this.enableScroll=function(){t.disableScroll=false},this.slidesCount=function(){return v}

Add this to the touch event:

if(!(e.touches.length>1||e.scale&&1!==e.scale)&&!t.disableScroll){ ... }

This will work for now I guess


#3

Theres already an open issue for this on github,

But you should put together a pull request and offer this as a solution!