/*
* pettanR system.js
- * version 0.5.23
+ * version 0.5.24
*
* gadgetOS
* author:
type = e.type,
list = hoverList,
i = 0,
- hit, parent;
- ++c;
+ ret, systemOnly = false, addClass, removeClass,
+ parent;
if( data && data.dispatchEvent( e, type, true ) === true ) return false;
- //if( p = targetNodeData ) while( p = p.parentData ) delete p.hitChild;
-
- currentRootData !== null && currentRootData._eventRellay( x, y, e, type );
- if( c > 20 ) c = 0;
+ targetNodeData = currentRootData;
+ currentRootData._capcher( x, y );
+ targetNodeData.apiuser.updateCoursor( targetNodeData._cursor );
+ data = targetNodeData;
+ while( data ){
+ ret = data.dispatchEvent( e, type, true, systemOnly );
+ if( ret === true || ret === false ) break; // systemOnly = true;
+ data = data.parentData;
+ };
+ addClass = Util.addClass;
+ removeClass = Util.removeClass;
for( ; i < list.length; ){
parent = data = list[ i ];
while( parent.parentData && parent === parent.parentData.hitChild ){
parent = parent.parentData;
};
if( parent !== currentRootData ){
- //if( data.parentData && data.parentData.hitChild !== data ){
- data.hover === true && Util.removeClass( data.elm, data.hoverClass );
+ data.hover === true && removeClass( data.elm, data.hoverClass );
delete data.isHover;
data.events && data.events.mouseout && data.fire( e, 'mouseout', false );
delete data.hitSelf;
list.splice( i, 1 );
- } else {
- ++i;
+ continue;
+ };
+ if( data.hover === true && data.isHover === false ){
+ addClass( data.elm, data.hoverClass );
+ data.isHover = true;
+ };
+ if( data.hitSelf === false ){
+ data.events && data.events.mouseover && data.fire( e, 'mouseover', true );
+ data.hitSelf = true;
};
+ ++i;
};
return false;
- };
+ };
var NodeClass = function( apiuser, rootData, /*parentLayer,*/ parentData, rangeOrElm, through, clip, hover, cursor, scroll, dragdrop ){
( new NodePrivateData() ).init( apiuser, rootData, /*parentLayer,*/ parentData, this, rangeOrElm, through, clip, hover, cursor, scroll, dragdrop );
list = this.events[ eventType ];
if( !list ){
list = this.events[ eventType ] = [];
- // node[ eventType ] = this._eventRellay;
} else {
for( i = list.length; i; ){
if( list[ --i ].match( eventType, handler ) === true ){
};
};
},
- _eventRellay : function( x, y, e, eventType ){
- if( this._disabled === true ) return false;
- var nodes, child, _x, _y, // = this.hitChild,
- hit, i;
- x -= this.x;
- y -= this.y;
- /**
- if( c > 20 || eventType !== 'mousemove' ){
- var depth = 0, p = this;
- while( p = p.parentData ){ ++depth; };
- console.log( '-'.repeat( depth ) + this.nodeIndex() + '\t\t' + eventType + '\tx:' + x + '\ty:' + y + '\tcX:' + e.clientX + '\tcY:' + e.clientY + ' nodes:' + this.numNode() + ' N.x:' + this.x + ' N.y:' + this.y + ' N.w' + this.w + ' N.h' + this.h + ' N.l' + this.l + ' N.t' + this.t + ' N.r' + this.r + ' N.b' + this.b );
- }; */
-
- delete this.hitChild;
-
- if( nodes = this.childData ){
- _x = x - this._scrollX;
- _y = y - this._scrollY;
+ _capcher : function( x, y ){
+ var t = this, nodes, child, _x, _y, hit, i;
+ if( t._disabled === true ) return false;
+ delete t.hitChild;
+ x -= t.x;
+ y -= t.y;
+ if( nodes = t.childData ){
+ _x = x - t._scrollX;
+ _y = y - t._scrollY;
for( i = nodes.length; i; ){
child = nodes[ --i ];
- if( child._disabled === false && child._hitRect( _x, _y ) === true && child._eventRellay( _x, _y, e, eventType ) === true ){
- this.hitChild = child;
+ if( child._disabled === false && child.l <= _x && _x < child.r && child.t <= _y && _y < child.b && child._capcher( _x, _y ) === true ){
+ t.hitChild = child;
break;
};
};
- };
-
- if( this.through === true ) return !!this.hitChild;
-
- hit = this._hitNode( x, y );
+ };
+ if( t.through === true ) return !!t.hitChild;
+ hit = 0 <= x && x < t.w && 0 <= y && y < t.h;
if( hit === true ){
- if( this.hitChild === null ){
- this.apiuser.updateCoursor( this._cursor );
- targetNodeData = this;
- };
- if( this.hover === true && this.isHover === false ){
- Util.addClass( this.elm, this.hoverClass );
- this.isHover = true;
- };
- this.hitSelf === false && hoverList.push( this ) && this.events && this.events.mouseover && this.fire( e, 'mouseover', true );
+ t.hitSelf === false && hoverList.push( t );
+ if( t.hitChild === null ) targetNodeData = t;
};
- this.hitSelf = hit || !!this.hitChild;
-
- if( this.hitSelf === false ) return false;
- if( !this.events || !this.events[ eventType ] ) return true;
- return this.dispatchEvent( e, eventType, true );
+ return hit || !!t.hitChild;
},
fire : function( e, eventType, hit ){
var list = this.events[ eventType ],
// console.log( eventType + ' x:' + x + ' y:' + y );
},
dispatchEvent : function( e, eventType, hit ){
- var ret, list, i, p;
- if( !this.events || !( list = this.events[ eventType ] ) ) return hit;
+ var ret, list, i, p, child;
+ if( !this.events || !( list = this.events[ eventType ] ) ) return;
+ child = !!this.hitChild;
e = NodePrivateData.createEvent( e, eventType, this, hit );
for( i = list.length; i; ){
- if( list[ --i ].fire( e ) === true ) ret = true;
- };
- if( this.hitChild ) return true;
- // target
- if( ret === true ){
- forceNodeData = this;
- // targetNodeData = this;
- this.apiuser.updateCoursor( this._cursor );
- return true;
- };
- if( hit === true ){
- forceNodeData = null;
- // targetNodeData = this;
- this.apiuser.updateCoursor( this._cursor );
- return true;
+ ret = list[ --i ].fire( e );
+ if( ret === true && child === false ){
+ forceNodeData = this;
+ return true;
+ };
+ if( ret === false ) return false;
};
forceNodeData = null;
- targetNodeData = null;
- return false;
- },
- _hitRect : function( x, y ){
- return this.l <= x && x < this.r && this.t <= y && y < this.b;
- },
- _hitNode : function( x, y ){
- return ( 0 <= x && x < this.w && 0 <= y && y < this.h ) || ( this === currentRootData );
},
onScrollReady : function( e ){
ScrollBarManager.show( this );
ScrollBarManager.hide( this );
},
scrollTo : function( x, y ){
-
+ this._scrollX = x;
+ this._scrollY = y;
+ ScrollBarManager.update( this );
},
scrollX : function( v ){
if( Type.isFinite( v ) === true ){
data.elmScroller.style.top = y + 'px';
};
if( data.scrollingY === data._scrollY ){
- smoothList.splice( i, 1 );
+ list.splice( i, 1 );
} else {
++i;
};