Flip the animation direction if the Hovercard is flipped

Change-Id: I890d49c517a52e57e0b22bcf1949b347d531d6b7
This commit is contained in:
Prateek Saxena 2014-05-27 17:41:52 +05:30
parent a52242087f
commit d1ddb95067
2 changed files with 28 additions and 5 deletions

View file

@ -276,6 +276,8 @@
/**
* Positions the popup based on the mouse position and popup size
* Default popup positioning is below and to the right of the mouse or link,
* unless flippedX or flippedY is true. flippedX and flippedY are cached.
*
* @method getOffset
* @param {jQuery} link
@ -288,8 +290,10 @@
flippedX = false,
flippedY = false,
settings = mw.popups.render.cache[ href ].settings,
offsetTop = ( event.pageY ) ?
offsetTop = ( event.pageY ) ? // If it was a mouse event
// Position according to mouse
event.pageY + 20 :
// Position according to link position or size
link.offset().top + link.height() + 9,
clientTop = ( event.clientY ) ?
event.clientY :
@ -318,6 +322,10 @@
flippedY = true;
}
if ( event.pageY && flippedY ) {
offsetTop += 30;
}
mw.popups.render.cache[ href ].settings.flippedY = flippedY;
return {
@ -342,6 +350,12 @@
flippedY = cache.settings.flippedY,
flippedX = cache.settings.flippedX;
if ( flippedY ) {
classes.push( 'mwe-popups-fade-in-down' );
} else {
classes.push( 'mwe-popups-fade-in-up' );
}
if ( flippedY && flippedX ) {
classes.push( 'flipped_x_y' );
}

View file

@ -130,7 +130,6 @@
.append( popup )
.show()
.attr( 'aria-hidden', 'false' )
.addClass( 'mwe-popups-fade-in-up' )
.on( 'mouseleave', mw.popups.render.leaveActive )
.on( 'mouseenter', function () {
if ( mw.popups.render.closeTimer ) {
@ -167,12 +166,22 @@
$( mw.popups.render.currentLink ).off( 'mouseleave blur', mw.popups.render.leaveActive );
var fadeInClass, fadeOutClass;
fadeInClass = ( mw.popups.$popup.hasClass( 'mwe-popups-fade-in-up' ) ) ?
'mwe-popups-fade-in-up' :
'mwe-popups-fade-in-down';
fadeOutClass = ( fadeInClass === 'mwe-popups-fade-in-up' ) ?
'mwe-popups-fade-out-down' :
'mwe-popups-fade-out-up';
mw.popups.$popup
.removeClass( 'mwe-popups-fade-in-up' )
.addClass( 'mwe-popups-fade-out-down' );
.removeClass( fadeInClass )
.addClass( fadeOutClass );
mw.popups.render.wait( 150 ).done( function () {
if ( mw.popups.$popup.hasClass( 'mwe-popups-fade-out-down' ) ) {
if ( mw.popups.$popup.hasClass( fadeOutClass ) ) {
mw.popups.$popup
.attr( 'aria-hidden', 'true' )
.hide()