检查css3动画是否已完成,例如使用jquery进行变换缩放(check if the css3 animation is done for example transform scale using jquery)
嘿,我正在处理一个带有应用于图像的css3动画的滑块。 现在我想检查css动画是否已经完成然后我只想改变滑块图像。 动画放在一个名为.animations的类中
.animationStuff { -moz-transform: scale(1.00); -webkit-transform: scale(1.00); -o-transform: scale(1.00); transform: scale(1.00); -ms-transform: scale(1.00); }
现在点击按钮我使用Jquery将animationSuff类添加到图像,我如何检查图像是否缩放到正常(我的意思是动画完成)? 谢谢
好的,我已经研究了一些,发现这个答案,它有效,但有一个问题,警报显示2次,反正这里是代码
$(firstBgImage).bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function() { alert('hello World'); });
有人能告诉我为什么当动画结束时它会显示两次,谢谢。
Hey i am working on a slider with css3 animations applied to images. Now i wanna check if the css animations have finished then only i wanna change the slider image. the animations are put in a class called .animations
.animationStuff { -moz-transform: scale(1.00); -webkit-transform: scale(1.00); -o-transform: scale(1.00); transform: scale(1.00); -ms-transform: scale(1.00); }
Now on button click i add the animationSuff class to image using Jquery, how can i check if the image has scaled to normal ( i mean the animation is finished)? thanks
Ok i've researched some more and found this answer and it works but there is one problem , the alert is displayed 2 times, anyways here is the code
$(firstBgImage).bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function() { alert('hello World'); });
Can someone tell me why it's displaying alter 2 times when animation ends, thanks.
原文:https://stackoverflow.com/questions/18558601
最满意答案
由with语句控制的块内的异常通过
generator.throw()
传播到生成器上下文管理generator.throw()
,如PEP 343:“Generator Decorator”所示 ,它在生成器暂停时引发异常。 换句话说,你应该在try / except或try / finally中包装yield
:@contextmanager def test(): print("Hello") try: # The block of the with statement executes when the generator yields yield finally: print("goodbye")
引用有关该主题的官方文档 :
...如果块中发生未处理的异常,则在生成器发生的点处将其重新加载。 因此,您可以使用try ... except ... finally语句来捕获错误(如果有),或确保进行一些清理。 如果仅为了记录异常或者为了执行某些操作(而不是完全禁止它)而捕获异常,则生成器必须重新加载该异常。 否则,生成器上下文管理器将向with语句指示已处理异常,并且将继续执行紧跟在with语句之后的语句。
The exception from within the block governed by the with statement is propagated to your generator context manager through
generator.throw()
as shown in PEP 343: "Generator Decorator", which raises the exception at the point where the generator was paused. In other words you should wrap theyield
in a try/except or try/finally:@contextmanager def test(): print("Hello") try: # The block of the with statement executes when the generator yields yield finally: print("goodbye")
To quote the official documentation on the subject:
...If an unhandled exception occurs in the block, it is reraised inside the generator at the point where the yield occurred. Thus, you can use a try…except…finally statement to trap the error (if any), or ensure that some cleanup takes place. If an exception is trapped merely in order to log it or to perform some action (rather than to suppress it entirely), the generator must reraise that exception. Otherwise the generator context manager will indicate to the with statement that the exception has been handled, and execution will resume with the statement immediately following the with statement.
相关问答
更多-
MDB异常处理(MDB exception handling)[2022-12-21]
无论抛出什么异常都会导致事务上下文进入仅回滚模式。 当onMessage返回时,将调用所有事务资源进行回滚。 这包括someUpdateMethod()中用于预准备语句的数据源。 要提交更新,必须在单独的事务中执行。 通过在方法上调用带有@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)的另一个无状态会话bean来执行此操作。 @MessageDriven(... public class MyMdb inpelements Messag ... -
这是一个非常全面的指导,我认为是必读: 异常和错误处理 - C ++常见问题或C ++常见问题 作为一般的经验法则,当您的程序可以识别出阻止执行的外部问题时,抛出异常。 如果您从服务器接收数据,并且数据无效,则抛出异常。 磁盘空间不足? 抛出异常 宇宙射线阻止您查询数据库? 抛出异常 但是如果您从自己的程序中获取一些无效数据 - 不要抛出异常。 如果你的问题来自你自己的坏代码,最好使用ASSERT来防范它。 需要异常处理来识别程序无法处理的问题,并告诉他们有关用户的问题,因为用户可以处理它们。 但程序中的错 ...
-
这肯定取决于你想要实现的目标 - 考虑如果你将使用#1方法,如果第一个might_throw_index_error出现问题,则下面的print和第二个might_throw_index_error 将永远不会被执行 。 另一方面,最后一个保证至少secon print将始终触发。 每种方法都很好,但这取决于您对应用程序流程的要求。 It definitely depends on what exactly you want to achieve - consider that if you will us ...
-
重新抛出的异常可以有不同的类型。 这在VS2012上编译和正确运行 // exceptions #include
using namespace std; int main () { try{ try { throw 20; } catch (int e) { cout << "An exception occurred. Exception Nr. " << e << '\n'; ... -
问题在于: fixdata = data[-1] 这实际上并不复制数据,它只复制对数据的引用 。 fixdata最终指向列表中的原始元素,所以当你这样做时 fixdata[10] = 'estimated' 它改变了原始数据。 要实际复制数据,请尝试以下方法: fixdata = data[-1][:] [:]复制整个列表,这是我认为你要做的。 The issue is in the line: fixdata = data[-1] That doesn't actually copy the da ...
-
如果"element1"等意味着是CSS选择器,那么最有效的方法是: elements = ["element1", "element2", "element3"] self.assertTrue(exists_in_new_window(",".join(elements))) (我已将is_exist_in_new_window重命名为exists_in_new_window 。)CSS中的运算符表示“或”。 因此传递给exists_in_new_window的CSS选择器意味着您正在寻找“eleme ...
-
由with语句控制的块内的异常通过generator.throw()传播到生成器上下文管理generator.throw() ,如PEP 343:“Generator Decorator”所示 ,它在生成器暂停时引发异常。 换句话说,你应该在try / except或try / finally中包装yield : @contextmanager def test(): print("Hello") try: # The block of the with statement ...
-
在Python 2中,当您退出捕获它的帧时,将清除sys.exc_info() 。 因此,如果将try..except放在函数中,退出该函数将清除sys.exc_info() 。 在Python 3中,当您退出异常处理程序时,将清除该信息。 因此,它可用于检测此帧或任何调用帧中是否引发异常。 如果你需要以某种方式检测是否在try..except的同一帧内处理异常,你可以提前调用sys.exc_clear()来促进这一点。 没有其他方法可以检测是否引发和处理了异常。 Python 2中的演示: >>> imp ...
-
你尝试过未处理的异常处理程序吗? Dim currentDomain As AppDomain = AppDomain.CurrentDomain AddHandler currentDomain.UnhandledException, AddressOf MyHandler Sub MyHandler(sender As Object, args As UnhandledExceptionEventArgs) Dim e As Exception = DirectCast(args.Excepti ...
-
是的,代码将继续。 在php中存在错误和异常。 您可以使用函数set_error_handler()处理错误,使用函数set_exception_handler()处理不可用的异常,并且可以使用try .. catch处理异常 Yes, code will continue. In php exists errors and exceptions. You can handle errors with function set_error_handler(), handle uncathable excep ...