jquery-based up and down seamless scrolling application (single or multiple lines)

Source: Internet
Author: User

<script>
$ (function () {
Single-line Application
var _wrap=$ (' Ul.line ');//define scrolling area
var _interval=2000;//defines the rolling gap time
var _moving;//animations that need to be cleared
_wrap.hover (function () {
Clearinterval (_moving);//When the mouse is in the scrolling area, stop scrolling
},function () {
_moving=setinterval (function () {
var _field=_wrap.find (' Li:first ');//This variable is not placed at the beginning of the function, the Li:first value is changed
var _h=_field.height ();//Get each scroll height
_field.animate ({margintop:-_h+ ' px '},600,function () {//) hides the first row by taking a negative margin value
_field.css (' margintop ', 0). AppendTo (_wrap);//After hiding, the margin value of the line is zeroed and inserted into the end, enabling seamless scrolling
})
},_interval)//scrolling interval depends on _interval
}). Trigger (' MouseLeave ');//When the function is loaded, the simulation executes the mouseleave, i.e. auto-scroll
});
$ (function () {
Multi-line applications
var _wrap=$ (' Ul.mulitline ');//define scrolling area
var _interval=3000;//defines the rolling gap time
var _moving;//animations that need to be cleared
_wrap.hover (function () {
Clearinterval (_moving);//When the mouse is in the scrolling area, stop scrolling
},function () {
_moving=setinterval (function () {
var _field=_wrap.find (' Li:first ');//This variable is not placed at the beginning of the function, the Li:first value is changed
var _h=_field.height ();//Get each scroll height
_field.animate ({margintop:-_h+ ' px '},600,function () {//) hides the first row by taking a negative margin value
_field.css (' margintop ', 0). AppendTo (_wrap);//After hiding, the margin value of the line is zeroed and inserted into the end, enabling seamless scrolling
})
},_interval)//scrolling interval depends on _interval
}). Trigger (' MouseLeave ');//When the function is loaded, the simulation executes the mouseleave, i.e. auto-scroll
});
</script>

jquery-based up and down seamless scrolling application (single or multiple lines)

Related Article

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.