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 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答