Toggle animation?

这一生的挚爱 提交于 2019-12-04 17:23:09

Just save the original value somewhere, and remember to stop any in-progress animation before starting a new one. The animation routines will take care of the rest:

var panel = $('.couch-hide');
var originalPos = panel.css("right");
panel.toggle(function() {
    $(this).stop().animate({right:0},1000, 'easeOutBounce');
  },
  function() {
    $(this).stop().animate({right:originalPos},1000, 'easeOutBounce');
  });
Vikram

Generally jquery toggle works pretty much in a standard way as given below, however i have not really tried it with animation stuff but this may work.

$('.couch-hide').click(function() {
    $(this).animate({right:0},1000, 'easeOutBounce').toggle();                       
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!