Merge "Merge a small piece of code duplication in SliderView"

This commit is contained in:
jenkins-bot 2024-02-02 09:13:50 +00:00 committed by Gerrit Code Review
commit 7f5b0d9cf4

View file

@ -906,14 +906,9 @@ $.extend( SliderView.prototype, {
this.backwardArrowButton.setDisabled( this.slider.isAtStart() ); this.backwardArrowButton.setDisabled( this.slider.isAtStart() );
this.forwardArrowButton.setDisabled( this.slider.isAtEnd() ); this.forwardArrowButton.setDisabled( this.slider.isAtEnd() );
const animateObj = { scrollLeft: this.slider.getOldestVisibleRevisionIndex() * this.revisionWidth };
if ( this.dir === 'rtl' ) {
animateObj.scrollLeft = this.getRtlScrollLeft( $animatedElement, animateObj.scrollLeft );
}
// eslint-disable-next-line no-jquery/no-animate // eslint-disable-next-line no-jquery/no-animate
$animatedElement.animate( $animatedElement.animate(
animateObj, { scrollLeft: this.getScrollLeft( $animatedElement ) },
duration, duration,
null, null,
function () { function () {
@ -939,11 +934,11 @@ $.extend( SliderView.prototype, {
/** /**
* @private * @private
* @param {jQuery} $element * @param {jQuery} $element
* @param {number} scrollLeft
* @return {number} * @return {number}
*/ */
getRtlScrollLeft: function ( $element, scrollLeft ) { getScrollLeft: function ( $element ) {
if ( this.rtlScrollLeftType === 'reverse' ) { const scrollLeft = this.slider.getOldestVisibleRevisionIndex() * this.revisionWidth;
if ( this.dir !== 'rtl' || this.rtlScrollLeftType === 'reverse' ) {
return scrollLeft; return scrollLeft;
} }
if ( this.rtlScrollLeftType === 'negative' ) { if ( this.rtlScrollLeftType === 'negative' ) {
@ -1146,11 +1141,7 @@ $.extend( SliderView.prototype, {
const revIdNew = this.getRevElementAtPosition( $revisions, this.getNewerPointerPos() ).data( 'revid' ); const revIdNew = this.getRevElementAtPosition( $revisions, this.getNewerPointerPos() ).data( 'revid' );
this.diffPage.replaceState( revIdNew, revIdOld, this ); this.diffPage.replaceState( revIdNew, revIdOld, this );
const scrollLeft = this.slider.getOldestVisibleRevisionIndex() * this.revisionWidth; $revisionContainer.scrollLeft( this.getScrollLeft( $revisionContainer ) );
$revisionContainer.scrollLeft( scrollLeft );
if ( this.dir === 'rtl' ) {
$revisionContainer.scrollLeft( this.getRtlScrollLeft( $revisionContainer, scrollLeft ) );
}
if ( this.shouldExpandSlider( $slider ) ) { if ( this.shouldExpandSlider( $slider ) ) {
this.expandSlider( $slider ); this.expandSlider( $slider );