Skip to content

Commit

Permalink
🛠 add preventScroll focus option #76, #651
Browse files Browse the repository at this point in the history
  • Loading branch information
desandro committed Apr 27, 2018
1 parent 903376e commit 9c56a46
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/flickity.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,10 @@ Flickity.keyboardHandlers = {
// ----- focus ----- //

proto.focus = function() {
// TODO remove scrollTo once focus options gets more support
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#Browser_compatibility
var prevScrollY = window.pageYOffset;
this.element.focus();
this.element.focus({ preventScroll: true });
// hack to fix scroll jump after focus, #76
if ( window.pageYOffset != prevScrollY ) {
window.scrollTo( window.pageXOffset, prevScrollY );
Expand Down

0 comments on commit 9c56a46

Please sign in to comment.