简体   繁体   English

jQuery SlideToggle()在缓动的每个步骤执行函数

[英]JQuery SlideToggle() execute function every step of the easing

Is there any way to execute an already defined function on javascript everytime a modification occurs in the animation of the easing of the slideToggle() function? 每次对slideToggle()函数的缓动动画进行修改时,是否有任何方法可以在javascript上执行已经定义的函数?

Example: 例:

SlideToggle("1000", "linear", functiontoexecute())

I would like functiontoexecute() to execute every step it occurs on the "linear" easing. 我希望functiontoexecute()执行它在“线性”缓动时发生的每个步骤。

I have already looked on JQuery webpage for .slideToggle() and tried to use "progress" or "step" options... but either they don't perform as expected or I didn't use them properly... 我已经在JQuery网页上查看了.slideToggle()并尝试使用“ progress”或“ step”选项...但是它们无法按预期执行,或者我没有正确使用它们...

For more details I am using JQuery 1.9.1 有关更多详细信息,我正在使用JQuery 1.9.1

The jQuery documentation on how to use those parameters isn't the best, as none of the examples use it to its full capabilities. 关于如何使用这些参数的jQuery文档并不是最好的,因为没有一个示例充分利用它的全部功能。 Here's an example using the progress function, but hopefully you can adapt this to whatever your needs are: - 这是使用进度功能的示例,但希望您可以将其适应您的需求:-

 $("#book") .slideToggle({ duration: 400, progress: functionToExecute, complete: function () { console.log('animation completed'); } }); function functionToExecute(animation, progress, remainingMs) { $('p').text('here and progress count is ' + progress); } 
 .wrap { height: 100px; width: 200px; margin: 10px 10px 10px 10px; background-color: #2d8cd0; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <div class="wrap" id="book"> <h2>1</h2> </div> <p>Progress: <span id="progress">0</span></p> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM