Would greatly appreciate your help in identifying errors in my script. Can someone point out where I might be going wrong?
I am using two plugins - the first for custom scrollbar changes, and the second which I have cut and pasted into the first call. Below is the code with some comments.
/* Setting custom scrollbar for content-section */
jQuery('.carousel-item').mCustomScrollbar({ axis:"y", theme: "rounded-dots", scrollButtons: { enable: true }, scrollInertia: 300,
callbacks:{
whileScrolling:function(){
/* this.mcs.draggerTop <- Accessed from the example on the official First plugin documentation */
var pct=this.mcs.draggerTop;
/* The following plugin is used to achieve a smooth scrolling effect, taken from the Second plugin available on GitHub. Below is an excerpt from jquery.fancy-scroll.js file. */
var defaults = {
animation: "bounce",
bounceDistance: 150,
animDuration: "0.3s",
animEasing: "cubic-bezier(0.175, 0.885, 0.420, 1.310)",
innerWrapper: '.carousel-item'
};
fancy_scroll = function(options){
var settings = $.extend({}, defaults, options),
el = $(settings.innerWrapper),
container = $(this),
posWas = 0,
status = "off";
$.fn.bounceEffect = function(px, s, anim, settings) {
var selector = $(this)
selector.css({
"-webkit-transform": "translate3d(0, " + px + ", 0)",
"-webkit-transition": "all " + s + " " + anim,
"-moz-transform": "translate3d(0, " + px + ", 0)",
"-moz-transition": "all " + s + " " + anim,
"-ms-transform": "translate3d(0, " + px + ", 0)",
"-ms-transition": "all " + s + " " + anim,
"transform": "translate3d(0, " + px + ", 0)",
"transition": "all " + s + " " + anim
})
}
if(pct==100){//if the user is scrolling down...
alert('dol');
if(status == "off") {
status = "on"
$('.carousel-item').bounceEffect(settings.bounceDistance * -1 + "px", settings.animDuration, settings.animEasing, settings);
$('.carousel-item').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
$('.carousel-item').bounceEffect("0", settings.animDuration, settings.animEasing, settings);
$('.carousel-item').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
status = "off"
});
});
}
}
if(pct==0){ //if the user is scrolling up...
if(status == "off") {
if(container.scrollTop() <= 0) {
status = "on"
$('.carousel-item').bounceEffect(settings.bounceDistance + "px", settings.animDuration, settings.animEasing, settings);
$('.carousel-item').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
$('.carousel-item').bounceEffect("0px", settings.animDuration, settings.animEasing, settings);
$('.carousel-item').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
status = "off"
});
});
}
}
}
}
fancy_scroll();
}
}
});
Warm regards