The effect of the Happy Lantern based on jquery (seamless text up and down) _jquery

Source: Internet
Author: User
(function ($) {
  $.fn.extend ({
    "Slideup": function (value) {  
      var docthis = this;
      Default parameter
      value=$.extend ({
         "li_h": "",
         "time": Watts,
         "Movetime": 1000
      },value)  
      //Slide up animation
      function Autoani () {
        $ ("Li:first", Docthis). Animate ({"Margin-top":-value.li_h},value.movetime,function () {
          $ (this). CSS ("Margin-top", 0). Appendto (". Line");
        }
      }
      Automatic interval time up sliding
      var anifun = setinterval (autoani,value.time);
      
      Stop sliding while hovering, and continue to execute
      $ (docthis) when you leave. Hover (function () {
        clearinterval (anifun);      Clear Automatic sliding animation
      },function () {
        setinterval (autoani,value.time);  Continue animation}})}
(jQuery)

Main ideas:

Sliding animation, is to change the position of elements, there are two ways to change the position of the elements, a change in the Left,top attributes (relative positioning and absolute positioning), there is one, is now used here, change the value of the margin.

Animation process in the example above:

1. Set the value to change the margin-top;

2. Change the Margin-top value of the first Li by animate method to 30 (negative values move up);

3. After the animation completes, in the callback function, changes the current first Li's margin-top to "0"

4. Move the current first Li to the last of all Li. (Achieve seamless)

Case download

The above is the entire content of this article, I hope to help you, thank you for the support of cloud habitat community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.