jquery scroll up to the top of several inserts

Source: Internet
Author: User
Tags min

1.Animated Scroll to top

Http://webdesignerwall.com/tutorials/animated-scroll-to-top


2.jQuery TopLink Plugin

3.Scroll to top Plugin

http://www.dynamicwp.net/plugins/scroll-to-top-plugin/

The code is as follows Copy Code

The jQuery JavaScript
//plugin
JQuery.fn.topLink = function (settings) {
 settings = Jquery.extend ({ br>   min:1,
  fadespeed:200
 , settings);
 return This.each (function () {
  //listen for scroll
  var el = $ (this);
   el.hide (); In case the user forgot
  $ (window). Scroll (function () {
   if ($ (window). scrolltop ( >= settings.min)
   {
    el.fadein (settings.fadespeed);
   &NBSP}
   else
   {
    el.fadeout ( Settings.fadespeed);
   }
  });
 });
};

Usage W/smoothscroll
$ (document). Ready (function () {
Set the link
$ (' #top-link '). TopLink ({
min:400,
fadespeed:500
});
Smoothscroll
$ (' #top-link '). Click (function (e) {
E.preventdefault ();
$.scrollto (0,300);
});
});


4.Disappearing "Scroll to Top" link with jQuery and CSS

The code is as follows Copy Code

The HTML
<div id= "Top" ></div>
<!--put all of the your normal content stuff here-->
<div id= "message" ><a href= ' top ' >scroll to top</a></div>
The CSS
#message A
{
/* Display:block before hiding * *
Display:block;
Display:none;

/* Link is above all other elements * *
z-index:999;

/* Link doesn ' t hide text behind it * *
Opacity:. 8;

/* link stays at same place on page */
position:fixed;

/* link goes at the bottom of the page * *
top:100%;
Margin-top: -80px; /* = height + preferred Bottom margin * *

/* Link is centered * *
left:50%;
Margin-left: -160px; /* = Half of width * *

/* Round the corners (to your preference) * *
-moz-border-radius:24px;
-webkit-border-radius:24px;

/* Make it big and easy to [size, style to preferences] *
width:300px;
line-height:48px;
height:48px;
padding:10px;
Background-color: #000;
font-size:24px;
Text-align:center;
Color: #fff;
}
The JQuery
$ (function () {

/* Set variables locally for increased performance * *
var Scroll_timer;
var displayed = false;
var $message = $ (' #message a ');
var $window = $ (window);
var top = $ (document.body). Children (0). Position ()-top;

/* React to scroll event on window * * *
$window. Scroll (function () {
Window.cleartimeout (Scroll_timer);
Scroll_timer = Window.settimeout (function () {
if ($window. scrolltop () <= top)
{
displayed = false;
$message. fadeout (500);
}
else if (displayed = False)
{
displayed = true;
$message. Stop (True, true). Show (). Click (function () {$message. fadeout (500);});
}
}, 100);
});
});


5.UItoTop jQuery Plugin

http://www.mattvarone.com/web-design/uitotop-jquery-plugin/

The code is as follows Copy Code

 
<style type= "text/css" media= "screen"
  *{margin:0 Auto;}
   #wrapper {width:90%;margin:15px auto;}
  p {margin:20px 0;}
</style>


<script type= "Text/javascript"
  $ (document). Ready (function () {
    /*
   var defaults = {
      containerid: ' Totop ',//Fading element id     containerhoverid: ' Totophover ',//fading element hover ID
     scrollspeed:1200,
    easingtype: ' linear '
    
    */
   
   $ (). Uitotop ({easingtype: ' Easeoutquart '});
   
  };
</script>

6.jQuery Scroll to top control v1.1

Http://www.dynamicdrive.com/dynamicindex3/scrolltop.htm

Instance

The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></ Script>

<script type= "Text/javascript" src= "Scrolltopcontrol.js" >

var scrolltotop={
Startline:integer. Number of pixels from top of doc ScrollBar are scrolled before showing control
Scrollto:keyword (Integer, or "scroll_to_element_id"). How far to scroll the document up as control was clicked on (0=top).
Setting: {startline:100, scrollto:0, scrollduration:1000, fadeduration:[500, 100]},
controlhtml: ' Controlattrs: {offsetx:5, offsety:5},//offset of control relative to right/bottom of window corner
Anchorkeyword: ' #top ',//enter href value of HTML anchors on the page so should also act as "Scroll up" links

State: {isvisible:false, shouldvisible:false},

 scrollup:function () {
  if (!this.cssfixedsupport)//if control is positioned using JavaScript
   this. $control. css ({opacity:0})//hide control immediately after clicking it
  var Dest=isnan (This.setting.scrollto)? This.setting.scrollto:parseInt (This.setting.scrollto)
  if (typeof dest== "string" && jQuery (' # ' +dest '. length==1)//check element set by string exists
   dest=jquery (' # ' +dest). Offset (). Top
  else
   dest=0
  this. $body. Animate ({scrolltop:dest}, This.setting.scrollduration);
 },

Keepfixed:function () {
var $window =jquery (window)
var controlx= $window. ScrollLeft () + $window. Width ()-this. $control. Width ()-This.controlattrs.offsetx
var controly= $window. scrolltop () + $window. Height ()-this. $control. Height ()-this.controlattrs.offsety
this. $control. css ({left:controlx+ ' px ', top:controly+ ' px '})
},

Togglecontrol:function () {
var scrolltop=jquery (window). scrolltop ()
if (!this.cssfixedsupport)
This.keepfixed ()
This.state.shouldvisible= (scrolltop>=this.setting.startline)? True:false
if (this.state.shouldvisible &&!this.state.isvisible) {
this. $control. Stop (). Animate ({opacity:1}, this.setting.fadeduration[0])
This.state.isvisible=true
}
else if (this.state.shouldvisible==false && this.state.isvisible) {
this. $control. Stop (). Animate ({opacity:0}, this.setting.fadeduration[1])
This.state.isvisible=false
}
},

Init:function () {
JQuery (document). Ready (function ($) {
var mainobj=scrolltotop
var Iebrws=document.all
Mainobj.cssfixedsupport=!iebrws | | Iebrws && document.compatmode== "Css1compat" && windows. XMLHttpRequest//not IE or ie7+ browsers in standards mode
Mainobj. $body = (window.opera)? (document.compatmode== "Css1compat"? $ (' HTML '): $ (' body ')): $ (' html,body ')
Mainobj. $control =$ (' <div id= topcontrol ' > ' +mainobj.controlhtml+ ' </div> ')
. css ({position:mainobj.cssfixedsupport? ' Fixed ': ' absolute ', bottom:mainobj.controlattrs.offsety, RIGHT:MAINOBJ.CONTROLATTRS.OFFSETX, opacity:0, cursor: ' Pointer '})
. attr ({title: ' Scroll Back to Top '})
. Click (function () {mainobj.scrollup (); return false})
. Appendto (' body ')
if (document.all &&!window. XMLHttpRequest && mainobj. $control. Text ()!= ')//loose check for IE6 and below, plus whether control contains any Text
Mainobj. $control. css ({width:mainobj. $control. Width ()})//ie6-seems to require a explicit width on a DIV containing text
Mainobj.togglecontrol ()
$ (' a[href= ' + Mainobj.anchorkeyword + ' "]"). Click (function () {
Mainobj.scrollup ()
return False
})
$ (window). bind (' Scroll resize ', function (e) {
Mainobj.togglecontrol ()
})
})
}
}

Scrolltotop.init ()

</script>


Setting: {startline:100, scrollto:0, scrollduration:1000, fadeduration:[500, 100]},
controlhtml: ' Controlattrs: {offsetx:15, offsety:15},//offset of control relative to right/bottom of window corner
Anchorkeyword: ' #top ',//enter href value of HTML anchors on the page so should also act as "Scroll up" links


7.Smooth gototop WordPress plugin

http://blog.mogosanu.ro/css/go-to-top-of-page-animat-cu-jquery/

Instance Code


Configurarea in Modul Avansat
Pentru a Configura distanta minima dupa care sa Apara butonul de gototop, Deschidem fisierul/jquery.top.js si mergem la l Inia 32.

The code is as follows Copy Code

................
$ (document). Ready (function () {

$ (' #top-link '). TopLink ({

min:400,//Inaltimea minima dupa care sa Apara butonul de gototop
fadespeed:500//Viteza de fading

});
....
DACA Dorim sa schimbam dimensiunea fontului sau chiar fontul o putem face Modificand Cateva linii in fisierul/gototop.php , Incepand cu Linia 45.

#top-link {

Display:none;
position:fixed;
right:5px;
bottom:5px;
height:18px;
Color: #000000;
font-family:arial;
font-size:11px;
Font-weight:bold;
Text-decoration:none;
Background: #90FF00; padding:5px;

}

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.