首页 \ 问答 \ 检查css3动画是否已完成,例如使用jquery进行变换缩放(check if the css3 animation is done for example transform scale using jquery)

检查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
更新时间:2023-11-01 08:11

最满意答案

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 the yield 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 tryexceptfinally 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.

相关问答

更多
  • 无论抛出什么异常都会导致事务上下文进入仅回滚模式。 当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 ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)