You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					98 lines
				
				2.1 KiB
			
		
		
			
		
	
	
					98 lines
				
				2.1 KiB
			| 
											3 years ago
										 | <!DOCTYPE html> | ||
|  | <html lang="it"> | ||
|  | 	<head> | ||
|  | 		<meta charset="utf-8" /> | ||
|  | 		<base href="../../../" /> | ||
|  | 		<script src="page.js"></script> | ||
|  | 		<link type="text/css" rel="stylesheet" href="page.css" /> | ||
|  | 	</head> | ||
|  | 	<body> | ||
|  | 		<h1>[name]</h1> | ||
|  | 
 | ||
|  | 		<p class="desc"> | ||
|  |       Eventi JavaScript per oggetti personalizzati.<br /> | ||
|  | 			[link:https://github.com/mrdoob/eventdispatcher.js EventDispatcher on GitHub] | ||
|  | 		</p> | ||
|  | 
 | ||
|  | 		<h2>Codice di Esempio</h2> | ||
|  | 
 | ||
|  | 		<code> | ||
|  | 		// Aggiungere eventi ad un oggetto custom | ||
|  | 
 | ||
|  | 		class Car extends EventDispatcher { | ||
|  | 
 | ||
|  | 			start() { | ||
|  | 
 | ||
|  | 				this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); | ||
|  | 
 | ||
|  | 			} | ||
|  | 
 | ||
|  | 		}; | ||
|  | 
 | ||
|  | 		// Usare gli eventi con l'oggetto custom | ||
|  | 
 | ||
|  | 		const car = new Car(); | ||
|  | 
 | ||
|  | 		car.addEventListener( 'start', function ( event ) { | ||
|  | 
 | ||
|  | 			alert( event.message ); | ||
|  | 
 | ||
|  | 		} ); | ||
|  | 
 | ||
|  | 		car.start(); | ||
|  | 		</code> | ||
|  | 
 | ||
|  | 		<h2>Costruttore</h2> | ||
|  | 
 | ||
|  | 		<h3>[name]()</h3> | ||
|  | 		<p> | ||
|  |       Crea un oggetto EventDispatcher. | ||
|  | 		</p> | ||
|  | 
 | ||
|  | 
 | ||
|  | 		<h2>Metodi</h2> | ||
|  | 
 | ||
|  | 		<h3>[method:undefined addEventListener]( [param:String type], [param:Function listener] )</h3> | ||
|  | 		<p> | ||
|  | 		  type - Il tipo di evento da ascoltare.<br /> | ||
|  | 		  listener - La funzione che viene chiamata quando viene generato l'evento. | ||
|  | 		</p> | ||
|  | 		<p> | ||
|  |       Aggiunge un listener ad un tipo di evento. | ||
|  | 		</p> | ||
|  | 
 | ||
|  | 		<h3>[method:Boolean hasEventListener]( [param:String type], [param:Function listener] )</h3> | ||
|  | 		<p> | ||
|  | 		  type - Il tipo di evento da ascoltare.<br /> | ||
|  | 		  listener - La funzione che viene chiamata quando viene generato l'evento. | ||
|  | 		</p> | ||
|  | 		<p> | ||
|  |       Verifica se il listener è aggiunto ad un tipo di evento. | ||
|  | 		</p> | ||
|  | 
 | ||
|  | 		<h3>[method:undefined removeEventListener]( [param:String type], [param:Function listener] )</h3> | ||
|  | 		<p> | ||
|  | 		  type - Il tipo di listener che viene rimosso.<br /> | ||
|  | 		  listener - La funzione listener che viene rimossa. | ||
|  | 		</p> | ||
|  | 		<p> | ||
|  |       Rimuove un listener da un tipo di evento. | ||
|  | 		</p> | ||
|  | 
 | ||
|  | 		<h3>[method:undefined dispatchEvent]( [param:Object event] )</h3> | ||
|  | 		<p> | ||
|  | 		  event - L'evento che viene lanciato. | ||
|  | 		</p> | ||
|  | 		<p> | ||
|  |       Lancia un tipo di evento. | ||
|  | 		</p> | ||
|  | 
 | ||
|  | 
 | ||
|  | 		<h2>Source</h2> | ||
|  | 
 | ||
|  | 		<p> | ||
|  | 			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] | ||
|  | 		</p> | ||
|  | 	</body> | ||
|  | </html> |