@@ -253,19 +253,7 @@ PIXI.InteractionManager.prototype.update = function()
253253 // OPTIMISE - how often to check??
254254 if ( this . dirty )
255255 {
256- this . dirty = false ;
257-
258- var len = this . interactiveItems . length ;
259-
260- for ( i = 0 ; i < len ; i ++ ) {
261- this . interactiveItems [ i ] . interactiveChildren = false ;
262- }
263-
264- this . interactiveItems = [ ] ;
265-
266- if ( this . stage . interactive ) this . interactiveItems . push ( this . stage ) ;
267- // go through and collect all the objects that are interactive..
268- this . collectInteractiveSprite ( this . stage , this . stage ) ;
256+ this . rebuildInteractiveGraph ( ) ;
269257 }
270258
271259 // loop through interactive objects!
@@ -317,6 +305,23 @@ PIXI.InteractionManager.prototype.update = function()
317305 }
318306} ;
319307
308+ PIXI . InteractionManager . prototype . rebuildInteractiveGraph = function ( )
309+ {
310+ this . dirty = false ;
311+
312+ var len = this . interactiveItems . length ;
313+
314+ for ( var i = 0 ; i < len ; i ++ ) {
315+ this . interactiveItems [ i ] . interactiveChildren = false ;
316+ }
317+
318+ this . interactiveItems = [ ] ;
319+
320+ if ( this . stage . interactive ) this . interactiveItems . push ( this . stage ) ;
321+ // go through and collect all the objects that are interactive..
322+ this . collectInteractiveSprite ( this . stage , this . stage ) ;
323+ } ;
324+
320325/**
321326 * Is called when the mouse moves across the renderer element
322327 *
@@ -326,6 +331,11 @@ PIXI.InteractionManager.prototype.update = function()
326331 */
327332PIXI . InteractionManager . prototype . onMouseMove = function ( event )
328333{
334+ if ( this . dirty )
335+ {
336+ this . rebuildInteractiveGraph ( ) ;
337+ }
338+
329339 this . mouse . originalEvent = event || window . event ; //IE uses window.event
330340 // TODO optimize by not check EVERY TIME! maybe half as often? //
331341 var rect = this . interactionDOMElement . getBoundingClientRect ( ) ;
@@ -356,6 +366,11 @@ PIXI.InteractionManager.prototype.onMouseMove = function(event)
356366 */
357367PIXI . InteractionManager . prototype . onMouseDown = function ( event )
358368{
369+ if ( this . dirty )
370+ {
371+ this . rebuildInteractiveGraph ( ) ;
372+ }
373+
359374 this . mouse . originalEvent = event || window . event ; //IE uses window.event
360375
361376 if ( PIXI . AUTO_PREVENT_DEFAULT ) this . mouse . originalEvent . preventDefault ( ) ;
@@ -399,6 +414,11 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
399414 */
400415PIXI . InteractionManager . prototype . onMouseOut = function ( )
401416{
417+ if ( this . dirty )
418+ {
419+ this . rebuildInteractiveGraph ( ) ;
420+ }
421+
402422 var length = this . interactiveItems . length ;
403423
404424 this . interactionDOMElement . style . cursor = 'inherit' ;
@@ -430,6 +450,10 @@ PIXI.InteractionManager.prototype.onMouseOut = function()
430450 */
431451PIXI . InteractionManager . prototype . onMouseUp = function ( event )
432452{
453+ if ( this . dirty )
454+ {
455+ this . rebuildInteractiveGraph ( ) ;
456+ }
433457
434458 this . mouse . originalEvent = event || window . event ; //IE uses window.event
435459
@@ -553,6 +577,11 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
553577 */
554578PIXI . InteractionManager . prototype . onTouchMove = function ( event )
555579{
580+ if ( this . dirty )
581+ {
582+ this . rebuildInteractiveGraph ( ) ;
583+ }
584+
556585 var rect = this . interactionDOMElement . getBoundingClientRect ( ) ;
557586 var changedTouches = event . changedTouches ;
558587 var touchData ;
@@ -589,6 +618,11 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
589618 */
590619PIXI . InteractionManager . prototype . onTouchStart = function ( event )
591620{
621+ if ( this . dirty )
622+ {
623+ this . rebuildInteractiveGraph ( ) ;
624+ }
625+
592626 var rect = this . interactionDOMElement . getBoundingClientRect ( ) ;
593627
594628 if ( PIXI . AUTO_PREVENT_DEFAULT ) event . preventDefault ( ) ;
@@ -645,6 +679,11 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
645679 */
646680PIXI . InteractionManager . prototype . onTouchEnd = function ( event )
647681{
682+ if ( this . dirty )
683+ {
684+ this . rebuildInteractiveGraph ( ) ;
685+ }
686+
648687 //this.mouse.originalEvent = event || window.event; //IE uses window.event
649688 var rect = this . interactionDOMElement . getBoundingClientRect ( ) ;
650689 var changedTouches = event . changedTouches ;
0 commit comments