The method of JavaScript to realize vertical sliding of picture div

Source: Internet
Author: User
Tags abs extend

the method of JavaScript to realize vertical sliding of picture div

This article mainly introduces the JavaScript implementation of the image div vertical sliding method, involving JavaScript operation Div Layer related skills, need friends can refer to the

This article illustrates the method of JavaScript to realize vertical sliding of picture div. Share to everyone for your reference. The implementation methods are as follows:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5, 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11 9 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146-147 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "><head> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> picture slide show effect </title> <script type=" Text/javascript "> var $$ = function (ID) { Return "string" = = typeof ID? document.getElementById (ID): ID; }; function Event (e) {var oevent = document.all? window.event:e; if (document.all) {if (Oevent.type = "Mouseout") {Oeven T.relatedtarget = oevent.toelement; }else if (Oevent.type = = "MouseOver") {oevent.relatedtarget = oevent.fromelement;}} return oevent; } function addEventHandler (Otarget, Seventtype, Fnhandler) {if (Otarget.addeventlistener) {Otarget.addeventlistener ( Seventtype, Fnhandler, false); else if (otarget.attachevent) {otarget.attachevent ("on" + Seventtype, Fnhandler);} else {otarget[' on ' + seventtype] = Fnhandler; } }; var Class = {CreaTe:function () {return function () {this.initialize.apply (this, arguments);}}} Object.extend = function (destination, source) {for (var property in source) {Destination[property] = Source[property];} return destination; }     var glideview = Class.create (); Glideview.prototype = {//Container object container width display label display width initialize:function (obj, iheight, Stag, imaxheight, options) {var ocontain er = $$ (obj), othis=this, len = 0; This. SetOptions (options); This. Step = Math.Abs (This.options.Step); This. Time = Math.Abs (this.options.Time); This._list = Ocontainer.getelementsbytagname (stag); len = this._list.length; This._count = Len; This._height = parseint (Iheight/len); This._height_max = parseint (imaxheight); This._height_min = parseint ((iheight-this._height_max)/(len-1)); This._timer = null; This. Each (function (olist, otext, i) {olist._target = This._height * i;//customizes a property to put the target left oList.style.top = olist._target + "px"; OList.style.position = "absolute"; addEventHandler (Olist, "MouseovEr ", function () {OThis.Set.call (othis, i);}); //Container style Set oContainer.style.height = iheight + "px"; OContainer.style.overflow = "hidden"; OContainer.style.position = "relative"; Returns the default state addEventHandler (Ocontainer, "mouseout", function (e) {//Workaround to prevent execution of olist mouseout var o = Event (e) When the container is removed. Relatedtarget; if (Ocontainer.contains!ocontainer.contains (o): Ocontainer!= o &&! ( Ocontainer.comparedocumentposition (o) &)) OThis.Set.call (Othis,-1); }),//Set default properties Setoptions:function (options) {this.options = {//default value step:20,//sliding rate time:3,//sliding delay TextTag: "",//Description container tag Te xtheight:0//description Container Height}; Object.extend (this.options, Options | | {}); The//Related Settings set:function (index) {if (Index < 0) {//mouse out of the container returns the default state this. Each (function (olist, otext, i) {olist._target = This._height * i; if (otext) {otext._target = This._height_text;}})} else {//mouse to move to this on a sliding object. Each (function (olist, otext, i) {olist._target = (i <= index)? This._height_min * I:this._height_min * (i-1) + this . _height_max; if (otext) {Otext._target = (i = = index)? 0:this._height_text;}) } this. Move (); },//Mobile Move:function () {cleartimeout (This._timer); var bfinish = true;//All reach destination address this. Each (function (olist, otext, i) {var inow = parseint (oList.style.top), Istep = this. Getstep (Olist._target, Inow); if (istep!= 0) {bfinish = false; OList.style.top = (Inow + istep) + "px";}}) The target continues to move if (!bfinish) {var othis = this; This._timer = settimeout (function () {othis.move ();}, this. Time); },//Get step Getstep:function (ITarget, Inow) {var istep = (itarget-inow)/this. Step; if (Istep = = 0) return 0; if (Math.Abs (Istep) < 1) return (Istep > 0? 1:-1); return istep; }, Each:function (fun) {for (var i = 0; i < this._count i++) Fun.call (this, this._list[i), (this. Showtext? This._text[i]: null), i); } }; </script> <style type= "Text/css" > #idGlideView {height:314px; width:325px; margin:0 auto; #idGlideView Div {width:325px height:314px;} </style> </head> ≪body> <div id= "Idglideview" > <div style= "background-color: #006699;" > mouse move here to try! </div> <div style= "Background-color: #FF9933;" > mouse move here to try! </div> </div> <div>http://www.jb51.net/</div> <SCRIPT> var gv = new Glideview (" Idglideview "," the "," the "," "div", 280, "" "); </SCRIPT> </body> </html>

The

wants this article to help you with your JavaScript programming.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.