Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added auto-focusing as an optional parameter.

  • Loading branch information...
commit 35f62f33c0efd281423b62d1cbcf2959c18b702b 1 parent 077f4c9
@jeff-optimizely authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 guiders-1.2.3.js
View
8 guiders-1.2.3.js
@@ -21,7 +21,8 @@ var guiders = (function($) {
guiders.version = "1.2.3";
guiders._defaultSettings = {
- attachTo: null,
+ attachTo: null, /* Selector of the element to attach to. */
+ autoFocus: true, /* Determines whether or not the browser scrolls to the element. */
buttons: [{name: "Close"}],
buttonCustomHTML: "",
classString: null,
@@ -401,8 +402,9 @@ var guiders = (function($) {
var guiderOffset = myGuider.elem.offset();
var guiderElemHeight = myGuider.elem.height();
- if (guiderOffset.top - scrollHeight < 0 ||
- guiderOffset.top + guiderElemHeight + 40 > scrollHeight + windowHeight) {
+ if (myGuider.autoFocus && (guiderOffset.top - scrollHeight < 0 ||
+ guiderOffset.top + guiderElemHeight + 40 > scrollHeight + windowHeight)) {
+ // Scroll to the guider's position.
window.scrollTo(0, Math.max(guiderOffset.top + (guiderElemHeight / 2) - (windowHeight / 2), 0));
}

0 comments on commit 35f62f3

Please sign in to comment.
Something went wrong with that request. Please try again.