diff --git a/modules/ext.RevisionSlider.SliderView.js b/modules/ext.RevisionSlider.SliderView.js index 5b46a72c..6b568da4 100644 --- a/modules/ext.RevisionSlider.SliderView.js +++ b/modules/ext.RevisionSlider.SliderView.js @@ -273,29 +273,38 @@ }, draggableDragAction: function ( event, ui, pointer, lastValidLeftPos ) { - var olderLeftPos, newerLeftPos, - isNew = $( pointer ).hasClass( 'mw-revslider-pointer-newer' ); + var pos, $revisions, $hoveredRevisionWrapper; - ui.position.left = Math.min( - ui.position.left, - this.getNewestVisibleRevisonLeftPos() + pos = this.getRevisionPositionFromLeftOffset( + $( pointer ).offset().left + this.revisionWidth / 2 ); - olderLeftPos = this.pointerOlder.getView().getElement().position().left; - newerLeftPos = this.pointerNewer.getView().getElement().position().left; + if ( pos === lastValidLeftPos ) { + return pos; + } - if ( ui.position.left === ( isNew ? olderLeftPos : newerLeftPos ) ) { - ui.position.left = lastValidLeftPos; - } else { - lastValidLeftPos = ui.position.left; - if ( this.dir === 'ltr' ) { - this.resetPointerColorsBasedOnValues( olderLeftPos, newerLeftPos ); + $revisions = this.getRevisionsElement(); + $hoveredRevisionWrapper = this.getRevElementAtPosition( $revisions, pos ).parent(); + this.slider.getRevisions().getView().showTooltip( $hoveredRevisionWrapper ); + + return pos; + }, + + getRevisionPositionFromLeftOffset: function ( leftOffset ) { + var $revisions = this.getRevisionsElement(), + revisionsX = mw.libs.revisionSlider.correctElementOffsets( $revisions.offset() ).left, + pos = Math.ceil( Math.abs( leftOffset - revisionsX ) / this.revisionWidth ); + + if ( this.dir === 'rtl' ) { + // pre-loading the revisions on the right side leads to shifted position numbers + if ( this.slider.isAtStart() ) { + pos = this.slider.getRevisionsPerWindow() - pos + 1; } else { - this.resetPointerColorsBasedOnValues( newerLeftPos, olderLeftPos ); + pos += this.slider.getRevisionsPerWindow(); } } - return lastValidLeftPos; + return pos; }, setPointerDragCursor: function () { @@ -920,8 +929,14 @@ this.slider.setRevisionsPerWindow( expandedRevisionWindowCapacity ); this.slide( Math.floor( ( this.pointerNewer.getPosition() - 1 ) / expandedRevisionWindowCapacity ), 0 ); - } + }, + /** + * @return {jQuery} + */ + getRevisionsElement: function () { + return this.slider.getRevisions().getView().getElement(); + } } ); mw.libs.revisionSlider = mw.libs.revisionSlider || {}; diff --git a/modules/ext.RevisionSlider.SliderViewTwo.js b/modules/ext.RevisionSlider.SliderViewTwo.js index a5657358..ec0030d1 100644 --- a/modules/ext.RevisionSlider.SliderViewTwo.js +++ b/modules/ext.RevisionSlider.SliderViewTwo.js @@ -115,24 +115,6 @@ SliderViewTwo.super.prototype.resetPointerStylesBasedOnPosition.call( this ); }, - draggableDragAction: function ( event, ui, pointer, lastValidLeftPos ) { - var pos, $revisions, $hoveredRevisionWrapper; - - pos = this.getRevisionPositionFromLeftOffset( - $( pointer ).offset().left + this.revisionWidth / 2 - ); - - if ( pos === lastValidLeftPos ) { - return pos; - } - - $revisions = this.getRevisionsElement(); - $hoveredRevisionWrapper = this.getRevElementAtPosition( $revisions, pos ).parent(); - this.slider.getRevisions().getView().showTooltip( $hoveredRevisionWrapper ); - - return pos; - }, - setPointerDragCursor: function () { $( '.mw-revslider-pointer, ' + '.mw-revslider-pointer-container, ' + @@ -203,23 +185,6 @@ this.alignPointers(); }, - getRevisionPositionFromLeftOffset: function ( leftOffset ) { - var $revisions = this.getRevisionsElement(), - revisionsX = mw.libs.revisionSlider.correctElementOffsets( $revisions.offset() ).left, - pos = Math.ceil( Math.abs( leftOffset - revisionsX ) / this.revisionWidth ); - - if ( this.dir === 'rtl' ) { - // pre-loading the revisions on the right side leads to shifted position numbers - if ( this.slider.isAtStart() ) { - pos = this.slider.getRevisionsPerWindow() - pos + 1; - } else { - pos += this.slider.getRevisionsPerWindow(); - } - } - - return pos; - }, - resetPointerStylesBasedOnPosition: function () { this.updateOlderSliderLineCSS(); this.updateNewerSliderLineCSS(); @@ -280,10 +245,6 @@ return this.pointerNewer.getPosition() - this.pointerOlder.getPosition(); }, - getRevisionsElement: function () { - return this.slider.getRevisions().getView().getElement(); - }, - revisionWrapperClickHandler: function () { } } ); diff --git a/tests/browser/features/history.feature b/tests/browser/features/history.feature index 51e20b5c..b76b5875 100644 --- a/tests/browser/features/history.feature +++ b/tests/browser/features/history.feature @@ -3,23 +3,25 @@ Feature: RevisionSlider history Background: Given a page with 4 revision(s) exists - Scenario: RevisionSlider history can be accessed using browser back and forward buttons after clicking on a revision - Given I am on the diff page - When I have loaded the RevisionSlider and dismissed the help dialog - And I click on revision 1 to move the lower pointer - And I wait until the diff has loaded - And I click on revision 2 to move the upper pointer - And I wait until the diff has loaded - And I click the browser back button - And I wait until the diff has loaded - And I click the browser back button - And I wait until the diff has loaded - And I click the browser forward button - And I wait until the diff has loaded - Then the lower pointer should be on revision 1 - And the upper pointer should be on revision 4 - And revision 1 should be loaded on the left of the diff - And revision 4 should be loaded on the right of the diff +# Deactivated until bar clicking will be reintroduced see T165831 +# +# Scenario: RevisionSlider history can be accessed using browser back and forward buttons after clicking on a revision +# Given I am on the diff page +# When I have loaded the RevisionSlider and dismissed the help dialog +# And I click on revision 1 to move the lower pointer +# And I wait until the diff has loaded +# And I click on revision 2 to move the upper pointer +# And I wait until the diff has loaded +# And I click the browser back button +# And I wait until the diff has loaded +# And I click the browser back button +# And I wait until the diff has loaded +# And I click the browser forward button +# And I wait until the diff has loaded +# Then the lower pointer should be on revision 1 +# And the upper pointer should be on revision 4 +# And revision 1 should be loaded on the left of the diff +# And revision 4 should be loaded on the right of the diff Scenario: RevisionSlider history can be accessed using browser back and forward buttons after dragging to a revision Given I am on the diff page diff --git a/tests/browser/features/pointers.feature b/tests/browser/features/pointers.feature index 616635b1..b720c2fb 100644 --- a/tests/browser/features/pointers.feature +++ b/tests/browser/features/pointers.feature @@ -3,17 +3,19 @@ Feature: RevisionSlider pointers Background: Given a page with 5 revision(s) exists - Scenario: RevisionSlider pointers move when revision bars are clicked - Given I am on the diff page - When I have loaded the RevisionSlider and dismissed the help dialog - And I click on revision 3 to move the lower pointer - And I wait until the diff has loaded - And I click on revision 4 to move the upper pointer - And I wait until the diff has loaded - Then the lower pointer should be on revision 3 - And the upper pointer should be on revision 4 - And revision 3 should be loaded on the left of the diff - And revision 4 should be loaded on the right of the diff +# Deactivated until bar clicking will be reintroduced see T165831 +# +# Scenario: RevisionSlider pointers move when revision bars are clicked +# Given I am on the diff page +# When I have loaded the RevisionSlider and dismissed the help dialog +# And I click on revision 3 to move the lower pointer +# And I wait until the diff has loaded +# And I click on revision 4 to move the upper pointer +# And I wait until the diff has loaded +# Then the lower pointer should be on revision 3 +# And the upper pointer should be on revision 4 +# And revision 3 should be loaded on the left of the diff +# And revision 4 should be loaded on the right of the diff Scenario: RevisionSlider pointers can be dragged Given I am on the diff page