Skip to content

Commit

Permalink
Remove cy prefix on event fields, because we don't merge with the o…
Browse files Browse the repository at this point in the history
…riginal event (as left open); e.g. `cyTarget` => `target` #1537
  • Loading branch information
maxkfranz committed Sep 21, 2016
1 parent be71557 commit d51613e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 50 deletions.
14 changes: 7 additions & 7 deletions src/define.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,12 @@ var define = {
if( eventsIsEvent ){ // then just get the object
evt = evtObj;

evt.cyTarget = evt.cyTarget || triggerer;
evt.target = evt.target || triggerer;
evt.cy = evt.cy || cy;

} else { // then we have to make one
evt = new Event( evtObj, {
cyTarget: triggerer,
target: triggerer,
cy: cy,
namespace: evtObj.namespace
} );
Expand All @@ -480,12 +480,12 @@ var define = {
}

// create a rendered position based on the passed position
if( evt.cyPosition ){
var pos = evt.cyPosition;
if( evt.position ){
var pos = evt.position;
var zoom = cy.zoom();
var pan = cy.pan();

evt.cyRenderedPosition = {
evt.renderedPosition = {
x: pos.x * zoom + pan.x,
y: pos.y * zoom + pan.y
};
Expand All @@ -503,7 +503,7 @@ var define = {
var lis = listeners[ k ];
var nsMatches = !lis.namespace || lis.namespace === evt.namespace || lis.namespace === define.event.universalNamespace;
var typeMatches = lis.type === evt.type;
var targetMatches = lis.delegated ? ( triggerer !== evt.cyTarget && is.element( evt.cyTarget ) && lis.selObj.matches( evt.cyTarget ) ) : (true); // we're not going to validate the hierarchy; that's too expensive
var targetMatches = lis.delegated ? ( triggerer !== evt.target && is.element( evt.target ) && lis.selObj.matches( evt.target ) ) : (true); // we're not going to validate the hierarchy; that's too expensive
var listenerMatches = nsMatches && typeMatches && targetMatches;

if( listenerMatches ){ // then trigger it
Expand Down Expand Up @@ -540,7 +540,7 @@ var define = {
}

// run the callback
var context = lis.delegated ? evt.cyTarget : triggerer;
var context = lis.delegated ? evt.target : triggerer;
var ret = lis.callback.apply( context, args );

if( ret === false || evt.isPropagationStopped() ){
Expand Down
6 changes: 3 additions & 3 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ var Event = function( src, props ){
// more efficient to manually copy fields we use
this.type = props.type !== undefined ? props.type : this.type;
this.cy = props.cy;
this.cyTarget = props.cyTarget;
this.cyPosition = props.cyPosition;
this.cyRenderedPosition = props.cyRenderedPosition;
this.target = props.target;
this.position = props.position;
this.renderedPosition = props.renderedPosition;
this.namespace = props.namespace;
this.layout = props.layout;
this.data = props.data;
Expand Down
8 changes: 4 additions & 4 deletions src/extensions/renderer/base/coord-ele-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ BRp.registerCalculationListeners = function(){
// nodes

.on('position.* style.* free.*', 'node', function onDirtyModNode( e ){
var node = e.cyTarget;
var node = e.target;

enqueue( node, e );
enqueue( node.connectedEdges(), e );
Expand All @@ -52,22 +52,22 @@ BRp.registerCalculationListeners = function(){
})

.on('add.* background.*', 'node', function onDirtyAddNode( e ){
var ele = e.cyTarget;
var ele = e.target;

enqueue( ele, e );
})

// edges

.on('add.* style.*', 'edge', function onDirtyEdge( e ){
var edge = e.cyTarget;
var edge = e.target;

enqueue( edge, e );
enqueue( edge.parallelEdges(), e );
})

.on('remove.*', 'edge', function onDirtyRemoveEdge( e ){
var edge = e.cyTarget;
var edge = e.target;
var pEdges = edge.parallelEdges();

for( var i = 0; i < pEdges.length; i++ ){
Expand Down
70 changes: 35 additions & 35 deletions src/extensions/renderer/base/load-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ BRp.load = function(){
if( ele ){
ele.trigger( new Event( e, {
type: 'taphold',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} ) );
} else {
cy.trigger( new Event( e, {
type: 'taphold',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} ) );
}
}
Expand All @@ -388,7 +388,7 @@ BRp.load = function(){

var cxtEvt = new Event( e, {
type: 'cxttapstart',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

if( near ){
Expand Down Expand Up @@ -419,7 +419,7 @@ BRp.load = function(){

var grabEvent = new Event( e, {
type: 'grab',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

setGrabTarget( near );
Expand Down Expand Up @@ -454,7 +454,7 @@ BRp.load = function(){
}

triggerEvents( near, [ 'mousedown', 'tapstart', 'vmousedown' ], e, {
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

if( near == null ){
Expand Down Expand Up @@ -568,7 +568,7 @@ BRp.load = function(){
preventDefault = true;

triggerEvents( near, [ 'mousemove', 'vmousemove', 'tapdrag' ], e, {
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

// trigger context drag if rmouse down
Expand All @@ -577,7 +577,7 @@ BRp.load = function(){
if( isOverThresholdDrag ){
var cxtEvt = new Event( e, {
type: 'cxtdrag',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

if( down ){
Expand All @@ -593,7 +593,7 @@ BRp.load = function(){
if( r.hoverData.cxtOver ){
r.hoverData.cxtOver.trigger( new Event( e, {
type: 'cxtdragout',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} ) );
}

Expand All @@ -602,7 +602,7 @@ BRp.load = function(){
if( near ){
near.trigger( new Event( e, {
type: 'cxtdragover',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} ) );
}

Expand Down Expand Up @@ -687,13 +687,13 @@ BRp.load = function(){

if( last ){
triggerEvents( last, [ 'mouseout', 'tapdragout' ], e, {
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );
}

if( near ){
triggerEvents( near, [ 'mouseover', 'tapdragover' ], e, {
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );
}

Expand Down Expand Up @@ -803,7 +803,7 @@ BRp.load = function(){
if( r.hoverData.which === 3 ){
var cxtEvt = new Event( e, {
type: 'cxttapend',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

if( down ){
Expand All @@ -815,7 +815,7 @@ BRp.load = function(){
if( !r.hoverData.cxtDragged ){
var cxtTap = new Event( e, {
type: 'cxttap',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

if( down ){
Expand Down Expand Up @@ -848,7 +848,7 @@ BRp.load = function(){
}

triggerEvents( near, [ 'mouseup', 'tapend', 'vmouseup' ], e, {
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );

if(
Expand All @@ -857,7 +857,7 @@ BRp.load = function(){
&& !r.hoverData.selecting // not box selection
){
triggerEvents( down, ['click', 'tap', 'vclick'], e, {
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} );
}

Expand Down Expand Up @@ -1026,7 +1026,7 @@ BRp.load = function(){

r.cy.trigger( new Event( e, {
type: 'mouseout',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} ) );
}, false );

Expand All @@ -1035,7 +1035,7 @@ BRp.load = function(){

r.cy.trigger( new Event( e, {
type: 'mouseover',
cyPosition: { x: pos[0], y: pos[1] }
position: { x: pos[0], y: pos[1] }
} ) );
}, false );

Expand Down Expand Up @@ -1113,21 +1113,21 @@ BRp.load = function(){
if( near1 && near1.isNode() ){
near1.activate().trigger( new Event( e, {
type: 'cxttapstart',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} ) );
r.touchData.start = near1;

} else if( near2 && near2.isNode() ){
near2.activate().trigger( new Event( e, {
type: 'cxttapstart',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} ) );
r.touchData.start = near2;

} else {
cy.trigger( new Event( e, {
type: 'cxttapstart',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} ) );
r.touchData.start = null;
}
Expand Down Expand Up @@ -1181,13 +1181,13 @@ BRp.load = function(){

near.trigger( new Event( e, {
type: 'grab',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} ) );
}
}

triggerEvents( near, [ 'touchstart', 'tapstart', 'vmousedown' ], e, {
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

if( near == null ){
Expand Down Expand Up @@ -1223,7 +1223,7 @@ BRp.load = function(){
&& !r.touchData.selecting // box selection shouldn't allow taphold through
){
triggerEvents( r.touchData.start, [ 'taphold' ], e, {
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

if( !r.touchData.start ){
Expand Down Expand Up @@ -1287,7 +1287,7 @@ BRp.load = function(){

var cxtEvt = new Event( e, {
type: 'cxttapend',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );
if( r.touchData.start ){
r.touchData.start.trigger( cxtEvt );
Expand All @@ -1302,7 +1302,7 @@ BRp.load = function(){
if( capture && r.touchData.cxt ){
var cxtEvt = new Event( e, {
type: 'cxtdrag',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );
r.data.bgActivePosistion = undefined;
r.redrawHint( 'select', true );
Expand All @@ -1323,7 +1323,7 @@ BRp.load = function(){
if( r.touchData.cxtOver ){
r.touchData.cxtOver.trigger( new Event( e, {
type: 'cxtdragout',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} ) );
}

Expand All @@ -1332,7 +1332,7 @@ BRp.load = function(){
if( near ){
near.trigger( new Event( e, {
type: 'cxtdragover',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} ) );

}
Expand Down Expand Up @@ -1553,12 +1553,12 @@ BRp.load = function(){
// touchmove
{
triggerEvents( (start || near), [ 'touchmove', 'tapdrag', 'vmousemove' ], e, {
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

if( ( !start || !start.grabbed() ) && near != last ){
if( last ){ last.trigger( new Event( e, { type: 'tapdragout', cyPosition: { x: now[0], y: now[1] } } ) ); }
if( near ){ near.trigger( new Event( e, { type: 'tapdragover', cyPosition: { x: now[0], y: now[1] } } ) ); }
if( last ){ last.trigger( new Event( e, { type: 'tapdragout', position: { x: now[0], y: now[1] } } ) ); }
if( near ){ near.trigger( new Event( e, { type: 'tapdragover', position: { x: now[0], y: now[1] } } ) ); }
}

r.touchData.last = near;
Expand Down Expand Up @@ -1675,7 +1675,7 @@ BRp.load = function(){
if( r.touchData.cxt ){
ctxTapend = new Event( e, {
type: 'cxttapend',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

if( start ){
Expand All @@ -1687,7 +1687,7 @@ BRp.load = function(){
if( !r.touchData.cxtDragged ){
var ctxTap = new Event( e, {
type: 'cxttap',
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

if( start ){
Expand Down Expand Up @@ -1772,7 +1772,7 @@ BRp.load = function(){
}

triggerEvents( start, [ 'touchend', 'tapend', 'vmouseup', 'tapdragout' ], e, {
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

start.unactivate();
Expand All @@ -1783,7 +1783,7 @@ BRp.load = function(){
var near = r.findNearestElement( now[0], now[1], true, true );

triggerEvents( near, [ 'touchend', 'tapend', 'vmouseup', 'tapdragout' ], e, {
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );

}
Expand Down Expand Up @@ -1820,7 +1820,7 @@ BRp.load = function(){
// Tap event, roughly same as mouse click event for touch
if( !r.touchData.singleTouchMoved ){
triggerEvents( start, [ 'tap', 'vclick' ], e, {
cyPosition: { x: now[0], y: now[1] }
position: { x: now[0], y: now[1] }
} );
}

Expand Down
Loading

0 comments on commit d51613e

Please sign in to comment.