douxian1895 2015-11-21 03:02
浏览 47
已采纳

jquery转移效果持有css结束

So I am making an app that utilizes the effect("transfer") from the query ui. Everything is working. But at the end of the animation the css tag that belongs to the effect .ui-effects-transfer just vanishes. I'd like it to stay on the page.

Is this possible?

here is my code javascript code.

  <script>
@foreach  ($stimuli['comparison'] as $stimulus)
    @if($stimuli['sample'][0] == $stimulus)

$("#sample").effect("transfer", {to: $("#{{ $stimulus }}")}, 9000);

        @endif
@endforeach


</script>

EDIT

So my instinct would be to make a second div for the css. and basically postiion it manually at the end of the animation. But I was wondering if there was a better and easier way? Because I want to keep element the same size as how the transfer is handling that css content image.

CSS

    .ui-effects-transfer {

    background-image :url("http://images.clipartpanda.com/finger-clipart-pointing-finger-md.png");
    opacity: .8;
    margin-top: 125px;
    z-index: 5 !important; 
  }

Issue http://jsfiddle.net/qq8q7357/3/

That is the issue I am.

During animation the picture is above everything. I want it to end by leaving the picture exactly where it is on top of the div rather then having set as a background image.

  • 写回答

1条回答 默认 最新

  • duancai7002 2015-11-21 05:08
    关注

    Use the functions complete method to add the class back to the element after the animation is complete. Here is the documentation

    Jquery UI

     $("#sample").effect("transfer", {to: $("#{{ $stimulus }}")}, 9000,function(){
           $('#{{ $stimulus }}').addClass('ui-effects-transfer');
     });
    

    EDIT:

    .ui-effects-transfer {
       background-image :url("http://images.clipartpanda.com/finger-clipart-pointing-finger-md.png") no-repeat;
       opacity: .8;
       z-index: 5 !important;
       background-size:20px 20px; //hand size
       // Use background postion not margin to move the image;
       background-position: 0px 125px;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动