当前位置: 首页 > 工具软件 > PleaseWait.js > 使用案例 >

Javascript应用--震撼的图片展示效果(图片换成你的图片名就可以运行了)

屠兴旺
2023-12-01
Code:
  1. <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>1</title>
  5. <metahttp-equiv="imagetoolbar"content="no">
  6. <styletype="text/css">
  7. html{
  8. overflow:hidden;
  9. }
  10. body{
  11. margin:0px;
  12. padding:0px;
  13. background:#000;
  14. width:100%;
  15. height:100%;
  16. }
  17. #imageFlow{
  18. position:absolute;
  19. width:100%;
  20. height:80%;
  21. left:0%;
  22. top:10%;
  23. background:#000;
  24. }
  25. #imageFlow.diapo{
  26. position:absolute;
  27. left:-1000px;
  28. cursor:pointer;
  29. -ms-interpolation-mode:nearest-neighbor;
  30. }
  31. #imageFlow.link{
  32. border:dotted#fff1px;
  33. margin-left:-1px;
  34. margin-bottom:-1px;
  35. }
  36. #imageFlow.bank{
  37. visibility:hidden;
  38. }
  39. #imageFlow.top{
  40. position:absolute;
  41. width:100%;
  42. height:40%;
  43. background:#181818;
  44. }
  45. #imageFlow.text{
  46. position:absolute;
  47. left:0px;
  48. width:100%;
  49. bottom:16%;
  50. text-align:center;
  51. color:#FFF;
  52. font-family:verdana,arial,Helvetica,sans-serif;
  53. z-index:1000;
  54. }
  55. #imageFlow.title{
  56. font-size:0.9em;
  57. font-weight:bold;
  58. }
  59. #imageFlow.legend{
  60. font-size:0.8em;
  61. }
  62. #imageFlow.scrollbar{
  63. position:absolute;
  64. left:10%;
  65. bottom:10%;
  66. width:80%;
  67. height:16px;
  68. z-index:1000;
  69. }
  70. #imageFlow.track{
  71. position:absolute;
  72. left:1%;
  73. width:98%;
  74. height:16px;
  75. filter:alpha(opacity=30);
  76. opacity:0.3;
  77. }
  78. #imageFlow.arrow-left{
  79. position:absolute;
  80. }
  81. #imageFlow.arrow-right{
  82. position:absolute;
  83. right:0px;
  84. }
  85. #imageFlow.bar{
  86. position:absolute;
  87. height:16px;
  88. left:25px;
  89. }
  90. </style>
  91. <scripttype="text/javascript">
  92. varimf=function(){
  93. varlf=0;
  94. varinstances=[];
  95. functiongetElementsByClass(object,tag,className){
  96. varo=object.getElementsByTagName(tag);
  97. for(vari=0,n=o.length,ret=[];i<n;i++)
  98. if(o[i].className==className)ret.push(o[i]);
  99. if(ret.length==1)retret=ret[0];
  100. returnret;
  101. }
  102. functionaddEvent(o,e,f){
  103. if(window.addEventListener)o.addEventListener(e,f,false);
  104. elseif(window.attachEvent)r=o.attachEvent('on'+e,f);
  105. }
  106. functioncreateReflexion(cont,img){
  107. varflx=false;
  108. if(document.createElement("canvas").getContext){
  109. flx=document.createElement("canvas");
  110. flx.width=img.width;
  111. flx.height=img.height;
  112. varcontext=flx.getContext("2d");
  113. context.translate(0,img.height);
  114. context.scale(1,-1);
  115. context.drawImage(img,0,0,img.width,img.height);
  116. context.globalCompositeOperation="destination-out";
  117. vargradient=context.createLinearGradient(0,0,0,img.height*2);
  118. gradient.addColorStop(1,"rgba(255,255,255,0)");
  119. gradient.addColorStop(0,"rgba(255,255,255,1)");
  120. context.fillStyle=gradient;
  121. context.fillRect(0,0,img.width,img.height*2);
  122. }else{
  123. /*----DXImageTransform----*/
  124. flx=document.createElement('img');
  125. flx.src=img.src;
  126. flx.style.filter='flipvprogid:DXImageTransform.Microsoft.Alpha('+
  127. 'opacity=50,style=1,finishOpacity=0,startx=0,starty=0,finishx=0,finishy='+
  128. (img.height*.25)+')';
  129. }
  130. /*----insertReflexion----*/
  131. flx.style.position='absolute';
  132. flx.style.left='-1000px';
  133. cont.appendChild(flx);
  134. returnflx;
  135. }
  136. /*====ImageFlowConstructor====*/
  137. functionImageFlow(oCont,size,zoom,border){
  138. this.diapos=[];
  139. this.scr=false;
  140. this.size=size;
  141. this.zoom=zoom;
  142. this.bdw=border;
  143. this.oCont=oCont;
  144. this.oc=document.getElementById(oCont);
  145. this.scrollbar=getElementsByClass(this.oc,'div','scrollbar');
  146. this.text=getElementsByClass(this.oc,'div','text');
  147. this.title=getElementsByClass(this.text,'div','title');
  148. this.legend=getElementsByClass(this.text,'div','legend');
  149. this.bar=getElementsByClass(this.oc,'img','bar');
  150. this.arL=getElementsByClass(this.oc,'img','arrow-left');
  151. this.arR=getElementsByClass(this.oc,'img','arrow-right');
  152. thisthis.bw=this.bar.width;
  153. thisthis.alw=this.arL.width-5;
  154. thisthis.arw=this.arR.width-5;
  155. thisthis.bar.parent=this.oc.parent=this;
  156. thisthis.arL.parent=this.arR.parent=this;
  157. thisthis.view=this.back=-1;
  158. this.resize();
  159. this.oc.onselectstart=function(){returnfalse;}
  160. /*----createimages----*/
  161. varimg=getElementsByClass(this.oc,'div','bank').getElementsByTagName('a');
  162. this.NF=img.length;
  163. for(vari=0,o;o=img[i];i++){
  164. this.diapos[i]=newDiapo(this,i,
  165. o.rel,
  166. o.title||'-'+i+'-',
  167. o.innerHTML||o.rel,
  168. o.href||'',
  169. o.target||'_self'
  170. );
  171. }
  172. /*====addmousewheelevents====*/
  173. if(window.addEventListener)
  174. this.oc.addEventListener('DOMMouseScroll',function(e){
  175. this.parent.scroll(-e.detail);
  176. },false);
  177. elsethis.oc.onmousewheel=function(){
  178. this.parent.scroll(event.wheelDelta);
  179. }
  180. /*====scrollbardragNdrop====*/
  181. this.bar.onmousedown=function(e){
  182. if(!e)e=window.event;
  183. varscl=e.screenX-this.offsetLeft;
  184. varself=this.parent;
  185. /*----movebar----*/
  186. this.parent.oc.onmousemove=function(e){
  187. if(!e)e=window.event;
  188. self.bar.style.left=Math.round(Math.min((self.ws-self.arw-self.bw),Math.max(self.alw,e.screenX-scl)))+'px';
  189. self.view=Math.round(((e.screenX-scl))/(self.ws-self.alw-self.arw-self.bw)*self.NF);
  190. if(self.view!=self.back)self.calc();
  191. returnfalse;
  192. }
  193. /*----releasescrollbar----*/
  194. this.parent.oc.onmouseup=function(e){
  195. self.oc.onmousemove=null;
  196. returnfalse;
  197. }
  198. returnfalse;
  199. }
  200. /*====rightarrow====*/
  201. thisthis.arR.onclick=this.arR.ondblclick=function(){
  202. if(this.parent.view<this.parent.NF-1)
  203. this.parent.calc(1);
  204. }
  205. /*====Leftarrow====*/
  206. thisthis.arL.onclick=this.arL.ondblclick=function(){
  207. if(this.parent.view>0)
  208. this.parent.calc(-1);
  209. }
  210. }
  211. /*====ImageFlowprototype====*/
  212. ImageFlow.prototype={
  213. /*====targets====*/
  214. calc:function(inc){
  215. if(inc)this.view+=inc;
  216. vartw=0;
  217. varlw=0;
  218. varo=this.diapos[this.view];
  219. if(o&&o.loaded){
  220. /*----reset----*/
  221. varob=this.diapos[this.back];
  222. if(ob&&ob!=o){
  223. ob.img.className='diapo';
  224. ob.z1=1;
  225. }
  226. /*----updatelegend----*/
  227. this.title.replaceChild(document.createTextNode(o.title),this.title.firstChild);
  228. this.legend.replaceChild(document.createTextNode(o.text),this.legend.firstChild);
  229. /*----updatehyperlink----*/
  230. if(o.url){
  231. o.img.className='diapolink';
  232. window.status='hyperlink:'+o.url;
  233. }else{
  234. o.img.className='diapo';
  235. window.status='';
  236. }
  237. /*----calculatetargetsizes&positions----*/
  238. o.w1=Math.min(o.iw,this.wh*.5)*o.z1;
  239. varx0=o.x1=(this.wh*.5)-(o.w1*.5);
  240. varx=x0+o.w1+this.bdw;
  241. for(vari=this.view+1,o;o=this.diapos[i];i++){
  242. if(o.loaded){
  243. o.x1=x;
  244. o.w1=(this.ht/o.r)*this.size;
  245. x+=o.w1+this.bdw;
  246. tw+=o.w1+this.bdw;
  247. }
  248. }
  249. x=x0-this.bdw;
  250. for(vari=this.view-1,o;o=this.diapos[i];i--){
  251. if(o.loaded){
  252. o.w1=(this.ht/o.r)*this.size;
  253. o.x1=x-o.w1;
  254. x-=o.w1+this.bdw;
  255. tw+=o.w1+this.bdw;
  256. lw+=o.w1+this.bdw;
  257. }
  258. }
  259. /*----movescrollbar----*/
  260. if(!this.scr&&tw){
  261. varr=(this.ws-this.alw-this.arw-this.bw)/tw;
  262. this.bar.style.left=Math.round(this.alw+lw*r)+'px';
  263. }
  264. /*----savepreviewview----*/
  265. thisthis.back=this.view;
  266. }
  267. },
  268. /*====mousewheelscrolling====*/
  269. scroll:function(sc){
  270. if(sc<0){
  271. if(this.view<this.NF-1)this.calc(1);
  272. }else{
  273. if(this.view>0)this.calc(-1);
  274. }
  275. },
  276. /*====resize====*/
  277. resize:function(){
  278. thisthis.wh=this.oc.clientWidth;
  279. thisthis.ht=this.oc.clientHeight;
  280. thisthis.ws=this.scrollbar.offsetWidth;
  281. this.calc();
  282. this.run(true);
  283. },
  284. /*====moveallimages====*/
  285. run:function(res){
  286. vari=this.NF;
  287. while(i--)this.diapos[i].move(res);
  288. }
  289. }
  290. /*====DiapoConstructor====*/
  291. Diapo=function(parent,N,src,title,text,url,target){
  292. this.parent=parent;
  293. this.loaded=false;
  294. this.title=title;
  295. this.text=text;
  296. this.url=url;
  297. this.target=target;
  298. this.N=N;
  299. this.img=document.createElement('img');
  300. this.img.src=src;
  301. thisthis.img.parent=this;
  302. this.img.className='diapo';
  303. thisthis.x0=this.parent.oc.clientWidth;
  304. thisthis.x1=this.x0;
  305. this.w0=0;
  306. this.w1=0;
  307. this.z1=1;
  308. thisthis.img.parent=this;
  309. this.img.onclick=function(){this.parent.click();}
  310. this.parent.oc.appendChild(this.img);
  311. /*----displayexternallink----*/
  312. if(url){
  313. this.img.onmouseover=function(){this.className='diapolink';}
  314. this.img.onmouseout=function(){this.className='diapo';}
  315. }
  316. }
  317. /*====Diapoprototype====*/
  318. Diapo.prototype={
  319. /*====HTMLrendering====*/
  320. move:function(res){
  321. if(this.loaded){
  322. varsx=this.x1-this.x0;
  323. varsw=this.w1-this.w0;
  324. if(Math.abs(sx)>2||Math.abs(sw)>2||res){
  325. /*----paintonlywhenmoving----*/
  326. this.x0+=sx*.1;
  327. this.w0+=sw*.1;
  328. if(this.x0<this.parent.wh&&this.x0+this.w0>0){
  329. /*----paintonlyvisibleimages----*/
  330. this.visible=true;
  331. varo=this.img.style;
  332. varh=this.w0*this.r;
  333. /*----diapo----*/
  334. o.left=Math.round(this.x0)+'px';
  335. o.bottom=Math.floor(this.parent.ht*.25)+'px';
  336. o.width=Math.round(this.w0)+'px';
  337. o.height=Math.round(h)+'px';
  338. /*----reflexion----*/
  339. if(this.flx){
  340. varo=this.flx.style;
  341. o.left=Math.round(this.x0)+'px';
  342. o.top=Math.ceil(this.parent.ht*.75+1)+'px';
  343. o.width=Math.round(this.w0)+'px';
  344. o.height=Math.round(h)+'px';
  345. }
  346. }else{
  347. /*----disableinvisibleimages----*/
  348. if(this.visible){
  349. this.visible=false;
  350. this.img.style.width='0px';
  351. if(this.flx)this.flx.style.width='0px';
  352. }
  353. }
  354. }
  355. }else{
  356. /*====imageonload====*/
  357. if(this.img.complete&&this.img.width){
  358. /*----getsizeimage----*/
  359. thisthis.iw=this.img.width;
  360. thisthis.ih=this.img.height;
  361. thisthis.r=this.ih/this.iw;
  362. this.loaded=true;
  363. /*----createreflexion----*/
  364. this.flx=createReflexion(this.parent.oc,this.img);
  365. if(this.parent.view<0)thisthis.parent.view=this.N;
  366. this.parent.calc();
  367. }
  368. }
  369. },
  370. /*====diapoonclick====*/
  371. click:function(){
  372. if(this.parent.view==this.N){
  373. /*----clickonzoomeddiapo----*/
  374. if(this.url){
  375. /*----openhyperlink----*/
  376. window.open(this.url,this.target);
  377. }else{
  378. /*----zoomin/out----*/
  379. thisthis.z1=this.z1==1?this.parent.zoom:1;
  380. this.parent.calc();
  381. }
  382. }else{
  383. /*----selectdiapo----*/
  384. thisthis.parent.view=this.N;
  385. this.parent.calc();
  386. }
  387. returnfalse;
  388. }
  389. }
  390. /*====publicmethods====*/
  391. return{
  392. /*====initializescript====*/
  393. create:function(div,size,zoom,border){
  394. /*----instanciateimageFlow----*/
  395. varload=function(){
  396. varloaded=false;
  397. vari=instances.length;
  398. while(i--)if(instances[i].oCont==div)loaded=true;
  399. if(!loaded){
  400. /*----pushnewimageFlowinstance----*/
  401. instances.push(
  402. newImageFlow(div,size,zoom,border)
  403. );
  404. /*----initscript(once)----*/
  405. if(!imf.initialized){
  406. imf.initialized=true;
  407. /*----windowresizeevent----*/
  408. addEvent(window,'resize',function(){
  409. vari=instances.length;
  410. while(i--)instances[i].resize();
  411. });
  412. /*----stopdragNdrop----*/
  413. addEvent(document.getElementById(div),'mouseout',function(e){
  414. if(!e)e=window.event;
  415. vartg=e.relatedTarget||e.toElement;
  416. if(tg&&tg.tagName=='HTML'){
  417. vari=instances.length;
  418. while(i--)instances[i].oc.onmousemove=null;
  419. }
  420. returnfalse;
  421. });
  422. /*----setintervalloop----*/
  423. setInterval(function(){
  424. vari=instances.length;
  425. while(i--)instances[i].run();
  426. },16);
  427. }
  428. }
  429. }
  430. /*----windowonloadevent----*/
  431. addEvent(window,'load',function(){load();});
  432. }
  433. }
  434. }();
  435. /*====createimageFlow====*/
  436. //divID,size,zoom,border
  437. imf.create("imageFlow",0.15,1.5,10);
  438. </script>
  439. </head>
  440. <body>
  441. <divid="imageFlow">
  442. <divclass="top"></div>
  443. <divclass="bank">
  444. <arel="ct37.jpg"title="Myselves"href="http://www.design-studio.cn/">MyidentityliesinnotknowingwhoIam</a>
  445. <arel="ct60.jpg"title="Discoveries"href="http://www.design-studio.cn/">...aremadebynotfollowinginstructions</a>
  446. <arel="sf53.jpg"title="Nothing"href="http://www.design-studio.cn/">...cancomebetweenus</a>
  447. <arel="sf48.jpg"title="Newlife"href="http://www.design-studio.cn/">Hereyoucome!</a>
  448. <arel="ct81.jpg"title="Optimists"href="http://www.design-studio.cn/">Theydon'tknowallthefactsyet</a>
  449. <arel="ct134.jpg"title="Empathy"href="http://www.design-studio.cn/">Emotionalintimacy</a>
  450. <arel="ct41.jpg"title="Muchwork"href="http://www.design-studio.cn/">...remainstobedonebeforewecanannounceourtotalfailuretomakeanyprogress</a>
  451. <arel="ct75.jpg"title="Systemerror"href="http://www.design-studio.cn/">ErrareProgrammaEst</a>
  452. <arel="bl201.jpg"title="Nonexistance"href="http://www.design-studio.cn/">There'snosuchthing</a>
  453. <arel="ct137.jpg"title="Inside"href="http://www.design-studio.cn/">I抦nowtrapped,withouthopeofescapeorrescue</a>
  454. <arel="ct65.jpg"title="E-Slaves"href="http://www.design-studio.cn/">TheWorldisflat</a>
  455. <arel="or105.jpg"title="l0v3"href="http://www.design-studio.cn/">1l0v3j00-f0r3v3r</a>
  456. <arel="ct139.jpg"title="Tminuszero"href="http://www.design-studio.cn/">111111111x111111111=12345678987654321</a>
  457. <arel="ct27.jpg"title="TheEnd"href="http://www.design-studio.cn/">...hasnotbeenwrittenyet</a>
  458. </div>
  459. <divclass="text">
  460. <divclass="title">Loading</div>
  461. <divclass="legend">Pleasewait...</div>
  462. </div>
  463. <divclass="scrollbar">
  464. <imgclass="track"src="sb.gif"alt="">
  465. <imgclass="arrow-left"src="sl.gif"alt="">
  466. <imgclass="arrow-right"src="sr.gif"alt="">
  467. <imgclass="bar"src="sc.gif"alt="">
  468. </div>
  469. </div>
  470. </body>
  471. </html>

 类似资料: