- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
如何通过 onmouseover 事件停止 cSlider 的自动播放功能?
HTML:
<div id="da-slider" class="da-slider">
<div class="da-slide">
<p>Text</p>
</div>
<div class="da-slide">
<p>More text</p>
</div>
</div>
到目前为止,我对 jQuery 的尝试:
$(function() {
$('#da-slider').cslider({
autoplay : true,
bgincrement : 450
});
});
$('#da-slider').hover(function() {
if($('#daslider').autoplay('true')){
autoplay: false
}
}, function () {
autoplay: true
});
这是我正在使用的:
http://tympanus.net/codrops/2012/03/15/parallax-content-slider-with-css3-and-jquery/
最佳答案
默认情况下未实现此功能,但这不应该阻止您自己实现它。查看下面修改后的插件代码(注意 stop
和 'start' 方法)
(function ($, undefined) {
/*
* Slider object.
*/
$.Slider = function (options, element) {
this.$el = $(element);
this._init(options);
};
$.Slider.defaults = {
current: 0, // index of current slide
bgincrement: 50, // increment the bg position (parallax effect) when sliding
autoplay: false, // slideshow on / off
interval: 4000 // time between transitions
};
$.Slider.prototype = {
_init: function (options) {
this.options = $.extend(true, {}, $.Slider.defaults, options);
this.$slides = this.$el.children('div.da-slide');
this.slidesCount = this.$slides.length;
this.current = this.options.current;
if (this.current < 0 || this.current >= this.slidesCount) {
this.current = 0;
}
this.$slides.eq(this.current).addClass('da-slide-current');
var $navigation = $('<nav class="da-dots"/>');
for (var i = 0; i < this.slidesCount; ++i) {
$navigation.append('<span/>');
}
$navigation.appendTo(this.$el);
this.$pages = this.$el.find('nav.da-dots > span');
this.$navNext = this.$el.find('span.da-arrows-next');
this.$navPrev = this.$el.find('span.da-arrows-prev');
this.isAnimating = false;
this.bgpositer = 0;
this.cssAnimations = Modernizr.cssanimations;
this.cssTransitions = Modernizr.csstransitions;
if (!this.cssAnimations || !this.cssAnimations) {
this.$el.addClass('da-slider-fb');
}
this._updatePage();
// load the events
this._loadEvents();
// slideshow
if (this.options.autoplay) {
this._startSlideshow();
}
},
_navigate: function (page, dir) {
var $current = this.$slides.eq(this.current), $next, _self = this;
if (this.current === page || this.isAnimating) return false;
this.isAnimating = true;
// check dir
var classTo, classFrom, d;
if (!dir) {
(page > this.current) ? d = 'next' : d = 'prev';
}
else {
d = dir;
}
if (this.cssAnimations && this.cssAnimations) {
if (d === 'next') {
classTo = 'da-slide-toleft';
classFrom = 'da-slide-fromright';
++this.bgpositer;
}
else {
classTo = 'da-slide-toright';
classFrom = 'da-slide-fromleft';
--this.bgpositer;
}
this.$el.css('background-position', this.bgpositer * this.options.bgincrement + '% 0%');
}
this.current = page;
$next = this.$slides.eq(this.current);
if (this.cssAnimations && this.cssAnimations) {
var rmClasses = 'da-slide-toleft da-slide-toright da-slide-fromleft da-slide-fromright';
$current.removeClass(rmClasses);
$next.removeClass(rmClasses);
$current.addClass(classTo);
$next.addClass(classFrom);
$current.removeClass('da-slide-current');
$next.addClass('da-slide-current');
}
// fallback
if (!this.cssAnimations || !this.cssAnimations) {
$next.css('left', (d === 'next') ? '100%' : '-100%').stop().animate({
left: '0%'
}, 1000, function () {
_self.isAnimating = false;
});
$current.stop().animate({
left: (d === 'next') ? '-100%' : '100%'
}, 1000, function () {
$current.removeClass('da-slide-current');
});
}
this._updatePage();
},
_updatePage: function () {
this.$pages.removeClass('da-dots-current');
this.$pages.eq(this.current).addClass('da-dots-current');
},
_startSlideshow: function () {
var _self = this;
this.slideshow = setTimeout(function () {
var page = (_self.current < _self.slidesCount - 1) ? page = _self.current + 1 : page = 0;
_self._navigate(page, 'next');
if (_self.options.autoplay) {
_self._startSlideshow();
}
}, this.options.interval);
},
page: function (idx) {
if (idx >= this.slidesCount || idx < 0) {
return false;
}
if (this.options.autoplay) {
clearTimeout(this.slideshow);
this.options.autoplay = false;
}
this._navigate(idx);
},
stop: function () {
if (this.options.autoplay) {
clearTimeout(this.slideshow);
this.options.autoplay = false;
}
},
start: function () {
this.options.autoplay = true;
this._startSlideshow();
},
_loadEvents: function () {
var _self = this;
this.$pages.on('click.cslider', function (event) {
_self.page($(this).index());
return false;
});
this.$navNext.on('click.cslider', function (event) {
if (_self.options.autoplay) {
clearTimeout(_self.slideshow);
_self.options.autoplay = false;
}
var page = (_self.current < _self.slidesCount - 1) ? page = _self.current + 1 : page = 0;
_self._navigate(page, 'next');
return false;
});
this.$navPrev.on('click.cslider', function (event) {
if (_self.options.autoplay) {
clearTimeout(_self.slideshow);
_self.options.autoplay = false;
}
var page = (_self.current > 0) ? page = _self.current - 1 : page = _self.slidesCount - 1;
_self._navigate(page, 'prev');
return false;
});
if (this.cssTransitions) {
if (!this.options.bgincrement) {
this.$el.on('webkitAnimationEnd.cslider animationend.cslider OAnimationEnd.cslider', function (event) {
if (event.originalEvent.animationName === 'toRightAnim4' || event.originalEvent.animationName === 'toLeftAnim4') {
_self.isAnimating = false;
}
});
}
else {
this.$el.on('webkitTransitionEnd.cslider transitionend.cslider OTransitionEnd.cslider', function (event) {
if (event.target.id === _self.$el.attr('id'))
_self.isAnimating = false;
});
}
}
}
};
var logError = function (message) {
if (this.console) {
console.error(message);
}
};
$.fn.cslider = function (options) {
if (typeof options === 'string') {
var args = Array.prototype.slice.call(arguments, 1);
this.each(function () {
var instance = $.data(this, 'cslider');
if (!instance) {
logError("cannot call methods on cslider prior to initialization; " +
"attempted to call method '" + options + "'");
return;
}
if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
logError("no such method '" + options + "' for cslider instance");
return;
}
instance[options].apply(instance, args);
});
}
else {
this.each(function () {
var instance = $.data(this, 'cslider');
if (!instance) {
$.data(this, 'cslider', new $.Slider(options, this));
}
});
}
return this;
};
})(jQuery);
使用更新的插件,您可以使用以下代码暂停和更新自动播放:
$('#da-slider').hover(
function () {
$(this).cslider("stop");
},
function () {
$(this).cslider("start");
}
);
关于javascript - cSlider : stop autoplay on mouseover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14341448/
我有一个问题,我的 WordPress 博客嵌入了来自 Imgur 的视频。加载后会自动播放。它还会自动循环。它与此嵌入 HTML 完美配合。但是,当我们将其滚动出屏幕时,它并不会停止。滚出时如何停止
关于为什么嵌入式YouTube视频无法在此站点上自动播放的任何想法? https://quantumleapin.wpengine.com/ 据我所知,自动播放功能已正确集成... 最佳答案 您的sr
因此,我使用Java来仅加载youtube视频的缩略图。单击拇指时,图像div完全替换为在“自动播放”中嵌入的视频。一切都按我想要的工作 在YouTube上,当我查看Google Analytics(
我在 asp.net 网站上使用谷歌音频播放器,我想在页面加载时默认设置 autoplay=true。 最佳答案 许多问题的一个解决方案使用下面的代码:) ........3523697345-aud
我的目标是制作一个自动重复和自动启动的视频幻灯片。不幸的是,视频似乎只是有时自动播放:根据我的实验,如果页面已经加载,或者从网站的其他部分导航到页面,重新加载页面时视频很可能会自动播放。由于该视频本来
我有一个 vimeo 视频,当用户单击 div 时会加载。 这是我的 JavaScript: $(".vimeobox").click(function() { var iframe
有人能帮帮我吗?我知道这里有一些错误。为什么我必须在页眉末尾和页面底部链接 bootstrap.min.js。我尝试一次使用一个,但它不起作用。接下来是我希望在加载页面和单击 Controller 时
我正在为移动用户创建一个 HTML5 音乐网站。目标是让它在移动浏览器中完全运行.. 问题是,当用户选择要播放的轨道时,他们会被带到“播放器”页面。然后我在 HTML5 音频元素中使用 AJAX,并将
如何通过 onmouseover 事件停止 cSlider 的自动播放功能? HTML: Text More text 到目前为止,我对 jQu
代码片段如下。我使用 impress.js 创建在线演示文稿。我想在最后一张幻灯片中插入一个视频,该视频在幻灯片出现时自动播放。但我无法实现这一点。谁能帮我解决这个问题吗? You
我正在使用 html5 视频标签在灯箱中显示视频。视频本身效果很好。但是当我尝试在有人打开灯箱时自动播放它时,我失败了。这是我正在使用的 JavaScript 代码。 触发灯箱的 HTML 工作正常。
我正在为应用程序使用 soundcloud API。我的代码做的第一件事就是在 soundcloud 上获取我最喜欢的轨道。每个轨道都使用 Jquery 显示为 li 元素。当我单击这些列表元素之一时
我有一个样式化组件,它可以为视频标签设置样式。 const Video = styled.video` ... ` 我也是这样用的 但是 autoplay 属性不起作用,当我使用 Dev
我得到了以下 HTML: 我将如何删除 autoplay完全来自 元素? 我试过类似下面的方法: //Attempt jQuery('video').remove('autoplay'); //At
到目前为止,我所有的研究和努力都在这方面碰壁:目前有什么方法可以让视频在 iOS 的 Safari 上自动播放吗? 有些人提到了视频转码或使用 playsinline(适用于 Android),但对
我需要能够在 Twitter Bootstrap 模式打开时自动播放 YouTube 视频,并随后在关闭时停止该视频。 我知道这个问题之前已经被问过,但我能找到的答案会导致包含许多视频的页面出现大量
我有一个使用 HTML5 设置的 ogg vorbis 文件 标签。 Firefox (3.6.13) 请求该文件两次,但使用“自动播放”选项时,两个请求的文件都会播放。 当我暂停时,其中一首轨道停止
A 获取一些带有 ?autoplay=1 的 URL 我想做一个 str.replace() 来删除这个 ?autoplay=1 来自 url。 现在我有这样的东西不起作用 val.replace('
我想通过 AMS 8 连接到我的主机上的 Mysql 数据库数据库远程已打开,我在远程 mysql 中添加了 % 以允许任何 IP 访问数据库你能给我一个简单的代码吗??? 最佳答案 您必须首先在 A
我遇到了这个问题。 我正在通过自定义字段传递它 here (注意“autoplay=1”) 但是当我使用 wp_oembed_get 在我的主题上加载视频时...它可以很好地显示视频,但它不会听取我的
我是一名优秀的程序员,十分优秀!