I need to yours help with improving errors in my scipt. Can anyone tell me what I make wrong?
我需要你的帮助来改善我的scipt中的错误。谁能告诉我我做错了什么?
I use two plugin. First is for change custom scrollbar, Second is cut by me and paste into first call. Below is code with comment.
我用两个插件。首先是更改自定义滚动条,第二个是由我剪切并粘贴到第一个调用。以下是带注释的代码。
/* Set 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 <- I get it from First script (official page) example: Returning values */
var pct=this.mcs.draggerTop;
/*Below plugin is used for nice scrolling effect. I get it from github Second script. Below code was in 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();
}
}
});
best regards
1 个解决方案
#1
0
I believe it was quite easily explained what I want to achieve.. I see that anyone can't help me. OK, I removed errors and I made code little simpler then earlier.
我相信很容易解释我想要实现的目标......我看到任何人都无法帮助我。好的,我删除了错误,之前我使代码变得更简单。
Thats my solution: custom scroll with effect when croll to top and bottom.
这就是我的解决方案:当croll到顶部和底部时自定义滚动效果。
/* Set custom scrollbar for content-section */
jQuery('.carousel-item').mCustomScrollbar({ axis:"y", theme: "rounded-dots", scrollButtons: { enable: true }, scrollInertia: 100,
callbacks:{
whileScrolling:function(){
var pct=this.mcs.topPct;
/*$("#mcs-dragger-top").text(this.mcs.topPct);*/
// alert(pct);
/*Plugin is used for nice scrolling effect*/
var settings = {
animation: "bounce",
bounceDistance: 60,
animDuration: "0.19s",
animEasing: "cubic-bezier(0.175, 0.885, 0.420, 1.310)" },
el = $('.carousel-item'),
container = $('.carousel-item'),
posWas = 0,
status = "off";
$.fn.bounceEffect = function(px, s, anim, settings) {
$('.carousel-item').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...
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") {
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"
});
});
}
}
}
}
});
I hope that will be helpfull for someone who search like that effect. If I have error in above code then please write here.
我希望这对那些搜索这种效果的人有所帮助。如果我在上面的代码中有错误,请写在这里。
best regards
#1
0
I believe it was quite easily explained what I want to achieve.. I see that anyone can't help me. OK, I removed errors and I made code little simpler then earlier.
我相信很容易解释我想要实现的目标......我看到任何人都无法帮助我。好的,我删除了错误,之前我使代码变得更简单。
Thats my solution: custom scroll with effect when croll to top and bottom.
这就是我的解决方案:当croll到顶部和底部时自定义滚动效果。
/* Set custom scrollbar for content-section */
jQuery('.carousel-item').mCustomScrollbar({ axis:"y", theme: "rounded-dots", scrollButtons: { enable: true }, scrollInertia: 100,
callbacks:{
whileScrolling:function(){
var pct=this.mcs.topPct;
/*$("#mcs-dragger-top").text(this.mcs.topPct);*/
// alert(pct);
/*Plugin is used for nice scrolling effect*/
var settings = {
animation: "bounce",
bounceDistance: 60,
animDuration: "0.19s",
animEasing: "cubic-bezier(0.175, 0.885, 0.420, 1.310)" },
el = $('.carousel-item'),
container = $('.carousel-item'),
posWas = 0,
status = "off";
$.fn.bounceEffect = function(px, s, anim, settings) {
$('.carousel-item').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...
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") {
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"
});
});
}
}
}
}
});
I hope that will be helpfull for someone who search like that effect. If I have error in above code then please write here.
我希望这对那些搜索这种效果的人有所帮助。如果我在上面的代码中有错误,请写在这里。
best regards