Skip to content

Commit

Permalink
Merge pull request #100 from WordPress/update/keep-block-position
Browse files Browse the repository at this point in the history
Keep the block position on the screen when moving blocks
  • Loading branch information
youknowriad committed Feb 20, 2017
2 parents 4b5f805 + 734653f commit cfa9765
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,11 @@ function attachControlActions() {
if ( getter ) {
node.addEventListener( 'click', function( event ) {
event.stopPropagation();
var previousOffset = selectedBlock.offsetTop;
swapNodes( selectedBlock, getter( selectedBlock ) );
attachBlockHandlers();
reselect();
window.scrollTo( window.scrollX, window.scrollY + selectedBlock.offsetTop - previousOffset );
}, false );
}
} );
Expand Down

0 comments on commit cfa9765

Please sign in to comment.