- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用SlidesJS ,这是一个非常可定制的幻灯片分页插件。
这是我的初始化。
$('.slides').slidesjs
({
width: 300,
height: 300,
navigation: false, // It's for swiping in an iOS web app
pagination: false,
generatePagination: false
});
但是,我不希望幻灯片以“相反的方式”环绕。我不知道有没有这个术语,所以我画了这个插图:
Green = Next
Blue = Previous
我想要的是禁用从 4 -> 1
或从 1 -> 4
的滑动。我还没有为此找到内置功能或属性。但是,有合理的解决方法吗?
最佳答案
伙计们!我成功了。
花了几个小时。
最初重新创建的问题是 here
我的工作解决方案,如下所述,是 here .
我找到了在哪里放置此循环效果的开关。
AND 我将其设置为新的选项
==> 循环
(真/假)!!!
如果 looping
选项设置为 false...它不会循环。
defaults = {
width: 940,
height: 528,
start: 1,
navigation: {
active: true,
effect: "slide"
},
pagination: {
active: true,
effect: "slide"
},
play: {
active: false,
effect: "slide",
interval: 5000,
auto: false,
swap: true,
pauseOnHover: false,
restartDelay: 2500
},
effect: {
slide: {
speed: 500
},
fade: {
speed: 300,
crossfade: true
}
},
callback: {
loaded: function() {},
start: function() {},
complete: function() {}
},
looping: false // Looping effect from last image to first and vice-versa
};
我稍微修改了 Plugin.prototype._slide
函数来实现此目的。
我基于 var
添加了一个新条件,我将其称为 OK_Proceed
。
默认情况下,此变量为 true
。
当尝试转到图像索引 -1
或 data.total
时,其值变为 false...但前提是循环选项设置为 false。
我希望保留原来的功能...
;)
var OK_Proceed=true; // ADDED var
console.log( this.options.looping );
if (next === -1) {
if( this.options.looping ){
next = this.data.total - 1;
}else{
OK_Proceed=false;
}
}
if (next === this.data.total) {
if( this.options.looping ){
next = 0;
}else{
OK_Proceed=false;
}
}
当此 OK_Proceed
为 false 时:脚本完全绕过动画函数。
它被一个小的 10px“反弹”效果所取代。
剩下要做的唯一一件事就是重置data.animating
值:
$.data(_this, "animating", false);
这是完整的功能:
Plugin.prototype._slide = function(number) { console.log("Line 430 - _slide: ");
var $element, currentSlide, direction, duration, next, prefix, slidesControl, timing, transform, value,
_this = this;
$element = $(this.element);
this.data = $.data(this); console.log( JSON.stringify( $.data(this) ) );
if (!this.data.animating && number !== this.data.current + 1) {
$.data(this, "animating", true);
currentSlide = this.data.current; console.log("Line 437 - currentSlide: "+currentSlide);
if (number > -1) {
number = number - 1;
value = number > currentSlide ? 1 : -1; console.log("Line 440 - value: "+value);
direction = number > currentSlide ? -this.options.width : this.options.width;
next = number;
} else {
value = this.data.direction === "next" ? 1 : -1;
direction = this.data.direction === "next" ? -this.options.width : this.options.width;
next = currentSlide + value; console.log("Line 446 - next: "+next);
} var OK_Proceed=true; // ADDED var
console.log( this.options.looping );
if (next === -1) {
if( this.options.looping ){
next = this.data.total - 1;
}else{
OK_Proceed=false;
}
}
if (next === this.data.total) {
if( this.options.looping ){
next = 0;
}else{
OK_Proceed=false;
}
}
if(OK_Proceed){this._setActive(next); // ADDED condition
slidesControl = $(".slidesjs-control", $element);
if (number > -1) {
slidesControl.children(":not(:eq(" + currentSlide + "))").css({
display: "none",
left: 0,
zIndex: 0
});
}
slidesControl.children(":eq(" + next + ")").css({
display: "block",
left: value * this.options.width,
zIndex: 10
});
this.options.callback.start(currentSlide + 1);
if (this.data.vendorPrefix) {
prefix = this.data.vendorPrefix;
transform = prefix + "Transform";
duration = prefix + "TransitionDuration";
timing = prefix + "TransitionTimingFunction";
slidesControl[0].style[transform] = "translateX(" + direction + "px)";
slidesControl[0].style[duration] = this.options.effect.slide.speed + "ms";
return slidesControl.on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", function() {
slidesControl[0].style[transform] = "";
slidesControl[0].style[duration] = "";
slidesControl.children(":eq(" + next + ")").css({
left: 0
});
slidesControl.children(":eq(" + currentSlide + ")").css({
display: "none",
left: 0,
zIndex: 0
});
$.data(_this, "current", next);
$.data(_this, "animating", false);
slidesControl.unbind("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd");
slidesControl.children(":not(:eq(" + next + "))").css({
display: "none",
left: 0,
zIndex: 0
});
if (_this.data.touch) {
_this._setuptouch();
}
return _this.options.callback.complete(next + 1);
});
} else {
return slidesControl.stop().animate({
left: direction
}, this.options.effect.slide.speed, (function() {
slidesControl.css({
left: 0
});
slidesControl.children(":eq(" + next + ")").css({
left: 0
});
return slidesControl.children(":eq(" + currentSlide + ")").css({
display: "none",
left: 0,
zIndex: 0
}, $.data(_this, "current", next), $.data(_this, "animating", false), _this.options.callback.complete(next + 1));
}));
} } else {
console.log("HERE");
$.data(_this, "animating", false);
console.log( JSON.stringify( $.data(this) ) );
// Bouncing effect
$(".slidesjs-control").stop().animate( { "left" : "-=10px" }, 100, "easeInOutBounce", function(){
$(".slidesjs-control").animate( { "left" : "+=10px" }, 100, "easeInOutBounce");
});
} // End added condition
}
};
我从所有console.logs中清除了这段代码并创建了一个zip file ready to use .
编辑后的第二天
为了使“触摸”的行为与鼠标单击的链接相同,还需要修改另外两个函数...上面的 .zip
文件也反射(reflect)了这些更改...
针对点击修改的函数为:_slide
。
针对点击修改的函数为:_setuptouch
和 _touchmove
。
有两个类可供您修改:bounceForward
和 bounceBackward
。
lastest demo is here 。在支持触摸的设备上尝试一下。
关于javascript - 在 SlidesJS 中禁用 "wrap around",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38406561/
我创建了一个包含社交图标的列表。这些图标应该环绕在小屏幕上。 我使用 flex-wrap: wrap; 它在 Firefox 和 Chrome 中完美运行: 但是 Internet Explorer
我很惊讶地发现我的 white-space: pre-wrap;文本在 > 换行和 "人物。我以为它只会换行,- , 以及一个或多个空格之后。 这是一个fiddle . 它在" 之后换行, 在
我被分配了重新创建以下网站的任务:https://plantanapp.com/learn 我做了一些事情,但是每次我解决一个问题时,都会出现另外两个问题。 我是HTML和CSS的新手,并不真正了解元
我偶然发现了 jQuery 的 wrap() 函数。 当我试图包装两个 div 标签时,它们之间有一些文本,而不是两个 div 之间没有文本时,它的行为不知何故不同。 j查询: var wrapper
我正在尝试在 w3c css 验证器上验证一个 css 文件。当它被测试时,它返回一个错误,指出 “属性 flex-wrap- 不存在:wrap”。这是我 css 验证器认为错误的部分。 .row {
这个问题在这里已经有了答案: Flex items create space between them when they wrap [duplicate] (1 个回答) 关闭 6 年前。 我正在
我正在制作一个网页,其中的标题有一个主要主题和一个描述符,每个都包含在标签中。 我已经查找了 标签,它似乎只在你有长字符串时才有效没有空格。但是我在文本中断断续续地有空格。 我需要的是我可以在两个元
我听到很多关于 wrap 面板加载速度较慢的消息,因此我们需要一个虚拟化面板。 有人可以给我一个小的环绕面板示例,它可以证明加载速度较慢等它需要一个虚拟面板。 我设置了一个环绕面板作为列表框的面板控件
我需要用 sinon 多次包装一个方法,以便能够根据参数返回不同的对象。我该怎么做? 我要测试的 Controller 看起来像这样: const servicePackagesOfferingRep
我在运行测试时收到了上述错误消息。下面是我的代码(我正在使用 Backbone JS 和 Jasmine 进行测试)。有谁知道为什么会这样? $(function() { describe("Ca
问题是关于.text-wrapper,它有display:flex; flex-wrap:wrap 应用于它。使用 flex-wrap:wrap 的原因是,否则 .text-wrapper 和 .ta
我有三个带有 Bootstrap 3 的 DIV 容器,其中前两个在第一行,第三个在下一行,直到浏览器宽度直到 991 px。高于 992 px,所有三个容器应排成一行。每行容器的高度应该是最高的 (
(我使用的是 Chrome v.39+) 我正在尝试使用 flex-wrap 属性水平和垂直堆叠子 div,但我看到了一些非常奇怪的行为。例如,如果有 3 个子 div,最后一个的宽度为 100%(使
我必须这样做。适用于宽屏、中屏和小屏 https://pp.vk.me/c629328/v629328337/21bd7/izp9QG8Qcg4.jpg 这是我的代码 .section-items-c
我想要一个每行 3 个元素的容器 flex div,问题是当我添加第四个元素时(它应该自动换行到第二行),而不是它停留在一行并缩小其他元素。我启用了 flex-wrap: wrap; 这是我的代码:
假设我正在使用一个带有 flex-direction:row 和 flex-wrap:wrap 的 flexbox 容器。 根据浏览器窗口的大小,每行中可能有 2、3、4 或更多项。 我想在每隔一行的
我已经添加了所有属性。当我更改浏览器宽度时,它们开始相互粘连,这是因为我有太多图像而无法正常工作? 无法将图像换行: #skills>div { margin-top: 80px; displ
我想制作一个网格,其中每行有两张图片。我正在使用 flex-wrap: wrap;它在 android 4.4+ 上运行良好,但不适用于低于 android 4.4 的系统。我想在不使用 flex-w
我的网站出现异常行为。我最近在网站管理员工具上发现,它发现我网站上的许多网页都出现抓取错误 404。我无法理解这些页面是如何创建的,因为所有 404 页面最后都包含这几个字 wrap-function
我正在使用 MongoDB C# 驱动程序构建一些更新语句。 The C# API在 Builder 命名空间中包括 Wrapped 和“Un-Wrapped”方法。 从表面上看,这些似乎因泛型不同而
我是一名优秀的程序员,十分优秀!