.stop() | JQuery API Documentation
Có thể bạn quan tâm
When .stop() is called on an element, the currently-running animation (if any) is immediately stopped. If, for instance, an element is being hidden with .slideUp() when .stop() is called, the element will now still be displayed, but will be a fraction of its previous height. Callback functions are not called.
If more than one animation method is called on the same element, the later animations are placed in the effects queue for the element. These animations will not begin until the first one completes. When .stop() is called, the next animation in the queue begins immediately. If the clearQueue parameter is provided with a value of true, then the rest of the animations in the queue are removed and never run.
If the jumpToEnd argument is provided with a value of true, the current animation stops, but the element is immediately given its target values for each CSS property. In our above .slideUp() example, the element would be immediately hidden. The callback function is then immediately called, if provided.
As of jQuery 1.7, if the first argument is provided as a string, only the animations in the queue represented by that string will be stopped.
The usefulness of the .stop() method is evident when we need to animate an element on mouseenter and mouseleave:
| 1 2 3 4 | <div id="hoverme"> Hover me <img id="hoverme" src="book.png" alt="" width="100" height="123"></div> |
We can create a nice fade effect without the common problem of multiple queued animations by adding .stop(true, true) to the chain:
| 1 2 3 4 5 | $( "#hoverme-stop-2" ).hover(function() { $( this ).find( "img" ).stop( true, true ).fadeOut();}, function() { $( this ).find( "img" ).stop( true, true ).fadeIn();}); |
Toggling Animations
As of jQuery 1.7, stopping a toggled animation prematurely with .stop() will trigger jQuery's internal effects tracking. In previous versions, calling the .stop() method before a toggled animation was completed would cause the animation to lose track of its state (if jumpToEnd was false). Any subsequent animations would start at a new "half-way" state, sometimes resulting in the element disappearing. To observe the new behavior, see the final example below.
Animations may be stopped globally by setting the property $.fx.off to true. When this is done, all animation methods will immediately set elements to their final state when called, rather than displaying an effect.
Từ khóa » Trong Jquery Effects Cú Pháp $(selector).stop(true) Có ý Nghĩa Gì
-
Phương Thức Stop() Trong JQuery | Cách Dừng Hiệu ứng Chuyển ...
-
Kết Thúc Hiệu ứng Bằng Phương Thức Stop() Trong JQuery
-
Phương Thức Stop() Trong JQuery, Có Ví Dụ Minh Họa - Thủ Thuật
-
Hiệu ứng Trong JQuery - Trần Ngọc Minh Notes
-
Hiệu ứng Trong Jquery - Thầy Long Web
-
Hiệu ứng Trong JQuery
-
JQuery Selector Là Gì? Trọn Bộ Selector Trong JQuery đầy đủ Nhất
-
JQuery: Dừng Hiệu ứng - Stop() | V1Study
-
[PDF] PHÁT TRIỂN ỨNG DỤNG WEB
-
Luan Van Thac Si Ky Thuat Lap Trinh Thoi Gian Bang Ngon Ngu Pp
-
Giáo Trình Phát Triển ứng Dụng Web: Phần 2 - Tài Liệu Text - 123doc
-
JQuery Animation - Chuyển đổi Kích Thước Mượt Mà - HelpEx
-
JQuery Là Gì? Tổng Quan Và Hướng Dẫn Sử Dụng JQuery
-
Cách Tạo Menu điều Hướng Thả Xuống Với HTML5, CSS3 Và JQuery