- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 jQuery 循环中遇到问题,只是忽略了所有命令(销毁、停止等)。此页面上还有很多其他内容,这些内容可能有所贡献,但我不确定有多少示例代码太多。
简而言之,我有两个同步幻灯片,它们在页面加载时初始化,当单击“.video-trigger”时,循环实例应该被销毁。但点击后,循环会继续循环(并覆盖本应取代它的视频)。
我已经尝试了我能想到的所有可能的场景来尝试找到源代码 - 删除所有其他 javascript(仅剩下循环和销毁单击事件),仅尝试调用并销毁两个幻灯片之一(而不是两者),在单独的包装器中调用它们。我什至删除了这两个循环实例,并在页面的完全不同部分制作了一个 super 简单的“测试”循环和单击事件,并且该循环实例也无法被销毁。不确定我错过了什么。
这里使用的另一个 jQuery 插件是 videojs,如果这是重要的话。
这是所有脚本,除了一个不相关的带有视频的 fancybox。如果包含所有内容有帮助,请告诉我,但我认为我可能已经包含了太多内容。
jQuery(document).ready(function($){
/// fading background images and video trigger
$('#background-image-wrapper,#trigger-fade').cycle();
// handle videos
$('.video-trigger').click(function() {
$('#background-image-wrapper,#trigger-fade').cycle('destroy');
var vidName = $(this).attr('id');
var vidID = 'video_' + vidName;
$('#background-image-wrapper').append('<div id="vid-cont" class="video-container"></div>');
$('#vid-cont').append('<video id="' + vidID + '" class="video-js vjs-default-skin" preload="auto" data-setup="{}">' +
'<source src="http://domain.com/wp-content/themes/sapporo/v/sapporo-'+ vidName +'.mp4" type="video/mp4">' +
'<source src="http://domain.com/wp-content/themes/sapporo/v/sapporo-'+ vidName +'.ogv" type="video/ogg">' +
'<source src="http://domain.com/wp-content/themes/sapporo/v/sapporo-'+ vidName +'.webm" type="video/webm">' +
'</video>');
//alert(vidID);
_V_(vidID).ready(function(){
var myPlayer = this;
var aspectRatio = 9/16;
function resizeVideoJS(){
//var width = document.getElementById(myPlayer.id).parentElement.offsetWidth; // Get the parent element's actual width -- this wasn't working with lower versions of FF
var width = document.getElementById('vid-cont').offsetWidth; // Get the parent element's actual width
myPlayer.width(width).height( width * aspectRatio ); // Set width to fill parent element, Set height
}
resizeVideoJS(); // Initialize the function
window.onresize = resizeVideoJS; // Call the function on resize
$('#trigger-fade').fadeOut();
$('#video-controls').fadeIn();
$('.video-container').css('left', '0');
myPlayer.volume(0);
myPlayer.play(); //start playing the video
var endedEvent = function(){
$('#video-controls').fadeOut(function(){ $('#trigger-fade').fadeIn(); });
$('.video-container').css('left', '-9999em');
$('.background-image').fadeIn('slow');
};
myPlayer.addEvent("ended", endedEvent);
$('#pause-video').click(function(){
myPlayer.pause();
$(this).fadeOut(function(){ $('#play-video').fadeIn(); });
});
$('#play-video').click(function(){
myPlayer.play();
$(this).fadeOut(function() { $('#pause-video').fadeIn(); });
});
$('#mute-video').click(function(){
myPlayer.volume(0);
$(this).fadeOut(function(){ $('#unmute-video').fadeIn(); });
});
$('#unmute-video').click(function(){
myPlayer.volume(.7);
$(this).fadeOut(function() { $('#mute-video').fadeIn(); });
});
$('#close-video').click(function(){
myPlayer.pause();
$('#video-controls').fadeOut(function(){ $('#trigger-fade').fadeIn(); });
$('.video-container').css('left', '-9999em');
$('.background-image').fadeIn('slow');
});
});
});
});
更新:我还没有更接近解决这个问题(无论我使用 Cycle 还是 Cycle2,它都会发生)。我已经实现了一个我不满意的解决方法(只是隐藏幻灯片,而它在视频播放时仍在运行)。但我确实注意到,在自定义循环后,然后尝试在不同的单击事件上暂停相同的幻灯片时,触发命令时,不会遵循该命令,但我之前为循环设置的所有自定义选项都会被覆盖。
即如果我从以下开始:
$('#background-image-wrapper,#trigger-fade').cycle({{timeout: 4000, speed: 7000}});
然后,在点击事件上使用它:
$('#background-image-wrapper,#trigger-fade').cycle('destroy');
或
$('#background-image-wrapper,#trigger-fade').cycle('pause');
然后,它基本上只是启动一个新的 Cycle 实例,而不是销毁或暂停,就好像“销毁/暂停”不存在一样。
最佳答案
关于jQuery Cycle 'destroy' 命令(和所有其他命令)被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14023170/
我有两个类(class): parent 和 child child : belongs_to :parent 和 家长 has_many :children, :dependent => :dest
我有这个模型 class XmlImport ["text/xml"] end :event_import_records 条目正在被销毁。但是 :events 不是。 has_many throu
我定义了以下简单的管道: image: name: hashicorp/terraform:light entrypoint: - '/usr/bin/env' - 'PATH
我定义了以下简单的管道: image: name: hashicorp/terraform:light entrypoint: - '/usr/bin/env' - 'PATH
在我们的应用程序中,我们覆盖了 ActiveRecord destroy 方法,以便我们的记录不会被删除(因此用户可以取消删除)。像这样: def destroy self.is_deleted
我有一个笔记模型,具有以下关联 注意.rb has_many :note_categories, :dependent => :destroy has_many :categories, :throu
我是一名 Python 初学者。尝试制作一个新按钮来关闭窗口。我收到错误消息: Exception in Tkinter callback Traceback (most recent call la
我在我的应用程序中添加了评论功能,到目前为止一切正常,直到出现此错误。我所做的是添加了删除评论功能。当我启动服务器时一切正常,但在我单击“删除”按钮后问题出现了。 错误信息 undefined loc
Rails,def destroy,没有响应 destroy.js.erb 这是我的方法: # DELETE /Groups/1 # DELETE /Groups/1.xml def de
假设我有一个 MyClass 对象的集合 MyCollection。 Set MyCollection = Nothing 是否调用每个包含的对象的析构函数,或者我应该单独设置每个对象 = Nothi
我正在尝试使用 Node.js、Express 和 Mongodb 构建 REST API。我正在使用 mongodb npm 包连接到数据库,下面是我的 sever.js 文件代码 var expr
我有一个小问题,我有以下两个模型: class CriticalProcess :destroy has_many :roles, :through => :authorizations a
我正在使用 ng2-toastr 并收到以下错误 https://www.npmjs.com/package/ng2-toastr Attempt to use a destroyed view: d
基本信息: 系统: # cat /proc/version Linux version 3.10.0-514.2.2.el7.x86_64 (builder@kbuilder.dev.centos.o
一 点睛 destroy 用于销毁 ThreadGroup,该方法只是针对一个没有任何 active 线程的 group 进行一次 destroy 标记,调用该方法的直接结果是在父 group 中将自
我开始注意到 Scope::Guard 的一些奇怪之处。 . 如果我取消定义 $guard变量作为 sub 中的最后一个语句,守卫的 sub 得到 比我预期的要晚打电话。 如果我不取消它,或者如果我做
我正在构建一个提供打开和关闭它的服务的模式。该模式有一个控制关闭按钮的小 Controller ,以及进入模式内容的模板的 $compile。 那个模板就是一个组件,当然,那个组件有一个 Contro
一直在文件馆和网上寻找答案,但没有真正找到答案,只是零零碎碎。似乎有很多建议的帖子,但没有一个有答案。 我有一个使用范围的复杂指令:true。它实际上是我正在尝试为其编写清理代码的 ng-grid 最
给定以下 Delphi 代码,Foo 在 FormClose 上是 Free,但 TFoo.Destroy 是没有被调用 - 因此 Bar 没有被 Free'd,导致内存泄漏? 我是否在这里错过了一些
https://docs.angularjs.org/guide/directive By listening to this event, you can remove event listener
我是一名优秀的程序员,十分优秀!