Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 17

Discussione: richiamare funzione

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    396

    richiamare funzione

    Ciao, ho questo script, ma non capisco quale sia la funzione principale da richiamare per farlo eseguire.
    codice:
    var diapo = function () {
    	var object = new Array(),
    	    K  = Math.PI / 180,
    	    N  = 0,
    	    xm = 0,
    	    ym = 0,
    	    mx = 0,
    	    my = 0,
    	    ax = 0,
    	    ay = 0,
    	    Nb = 0,
    	    tit = 0,
    	    img = 0;
    ////////////////////
    	var zM = 4;
    ////////////////////
    	var CObj = function (N, x, y, z){
    		var I = img.getElementsByTagName("img")[N % img.getElementsByTagName("img").length];
    		var o = document.createElement("img");
    		o.onclick = function () {
    			if (object[N].on == true) object[N].on = false;
    			else object[N].on = true;
    		}
    		o.onmouseover = function () {
    			if (Nb != N) {
    				Nb = N;
    				tit.innerHTML= I.alt;
    			}
    		}
    		o.onmouseout = function () {
    			Nb = -1;
    			object[N].on = false;
    		}
    		o.onmousedown = new Function("return false");
    		o.src = I.src;
    		scr.appendChild(o);
    		this.obj  = o.style;
    		this.z    = Math.round(z * ny * .25);
    		this.x    = Math.round(x * ny * .25);
    		this.y    = Math.round(y * ny * .25);
    		this.on   = false;
    		this.zOOm = 1;
    		this.N    = N;
    	}
    
    	CObj.prototype.anim = function () {
    		var xP = this.z * Math.sin(mx * K) + this.x  * Math.cos(mx * K);
    		var zP = this.z * Math.cos(mx * K) - this.x  * Math.sin(mx * K);
    		var yP = this.y * Math.cos(my * K) - zP * Math.sin(my * K);
    		zP = this.y * Math.sin(my * K) + zP * Math.cos(my * K);
    		var w = (zP * .25 + ny * .25) * this.zOOm;
    		var h = w * .8;
    		if (this.on && zP > 0) {
    			if (this.zOOm < zM) this.zOOm += .05;
    		} else {
    			if (this.zOOm > 1) this.zOOm -= .025;
    		}
    		this.obj.left   = Math.round(xP + nx * .5 - w * .5) + "px";
    		this.obj.top    = Math.round(yP + ny * .5 - h * .5) + "px";
    		this.obj.width  = Math.round(w) + "px";
    		this.obj.height = Math.round(h) + "px";
    		this.obj.zIndex = Math.round(1000 + w);
    	}
    
    	var run = function () {
    		dx = (1 * xm) - mx;
    		dy = (1 * ym) - my;
    		mx += dx / 60;
    		my += dy / 60;
    		var i = 0, o;
    		while (o = object[i++]) o.anim();
    		setTimeout(run, 16);
    	}
    
    	var resize = function () {
    		nx = scr.offsetWidth;
    		ny = scr.offsetHeight * .9;
    	}
    
    	var init = function () {
    		scr = document.getElementById("screen");
    		img = document.getElementById("img");
    		tit = document.getElementById("tit");
    		resize();
    		scr.onselectstart = new Function("return false");
    		onresize = resize;
    		scr.onmousemove = function(e){
    			if (window.event) e = window.event;
    			xm = (e.x || e.clientX);
    			ym = (e.y || e.clientY);
    		}
    		object.push( new CObj(0,1,-1,-1) );
    		object.push( new CObj(1,1,1,-1) );
    		object.push( new CObj(2,-1,-1,-1) );
    		object.push( new CObj(3,-1,1,-1) );
    		object.push( new CObj(4,1,-1,1) );
    		object.push( new CObj(5,1,1,1) );
    		object.push( new CObj(6,-1,-1,1) );
    		object.push( new CObj(7,-1,1,1) );
    		run();
    	}
    	////////////////////////////////////////////////////////////
    	return {
    		init : init
    	}
    }();
    
    onload = function (){
    	diapo.init();
    }
    ho provato con diapo.init() da avviare al click di un pulsante, ma non va.
    Mi date una mano?

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    396
    up

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    posta il codice html dove si trovano gli elementi screen, img e tit

  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    396
    codice:
    <body>
    
    <div id="screen">
    	<div id="img">
    		[img]41800.jpg[/img]
    		[img]20800.jpg[/img]
    		[img]238000.jpg[/img]
    		[img]44800.jpg[/img]
    		[img]49800.jpg[/img]
    		[img]218000.jpg[/img]
    		[img]23800.jpg[/img]
    		[img]47800.jpg[/img]
    	</div>
    	<div id="tit" ></div>
    </div>
    
    </body>

  5. #5
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    facendo una chiamata a diapo.init(); lo script sembra funzionare, in allegato quello che vedo in pagina.

  6. #6
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    mmm... metto l'allegato ma non si vede, cmq sembra funzionare... cosa dovrebbe fare lo script?

  7. #7
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    396
    Dovrebbe essere una galleria di immagini in 3d

  8. #8
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    396
    A me con il comando diapo.init() non parte niente, neanche un messaggio d'errore...

  9. #9
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    Anche a me non da messaggi di errore, diciamo che vedo le immagini ingrandirsi e rimpicciolirsi... non so neanche io come descriverlo... ma cmq qualcosa fa!

  10. #10
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    396
    Si, è vero, adesso parte anche a me.
    Purtroppo non riesco ad impaginarlo correttamente.
    Ti mando anche il .css
    codice:
    html {
    		overflow: hidden;
    	}
    	body {
    		background: #000;
    		width:100%;
    		height:100%;
    		margin:0;
    	}
    	#screen {
    		position: absolute;
    		width: 100%;
    		height: 100%;
    	}
    
    	#img {
    		visibility: hidden;
    	}
    	#screen img  {
    		position:absolute;
    		left:-10000px;
    		z-index:100;
    		-ms-interpolation-mode:nearest-neighbor;
    		image-rendering: optimizeSpeed;
    		cursor: pointer;
    		border:#333 solid 1px;
    	}
    	#tit {
    		text-align:center;
    		position:absolute;
    		color:#fff;
    		font-family:verdana;
    		font-weight:bold;
    		font-size:48px;
    		filter: alpha(opacity=30);
    		opacity: 0.3;
    		width:100%;
    		bottom:12px;
    		z-index:10000;
    	}
    Ho cercato di mettere lo script dentro un div della mia pagina, ma il risultato non è quello desiderato.
    Gli unici dati che non ho ricopiato nel mio css sono la definizione di "html" e "body"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.