docs: function checkScroll() {
              if (!$.isScrollToFixed(target) || target.is(':hidden')) return;
              var wasReset = isReset;
              var wasUnfixed = isUnfixed();
  
              // If resetScroll has not yet been called, call it. This only
              // happens once.
              if (!isReset) {
                  resetScroll();
              } else if (isUnfixed()) {
                  // if the offset has changed since the last scroll,
                  // we need to get it again.
  
                  // Capture the offset top of the target element.
                  offsetTop = target.offset().top;
  
                  // Capture the offset left of the target element.
                  offsetLeft = target.offset().left;
              }
  
              // Grab the current horizontal scroll position.
              var x = $(window).scrollLeft();
  
              // Grab the current vertical scroll position.
              var y = $(window).scrollTop();
  
              // Get the limit, if there is one.
              var limit = getLimit();
  
              // If the vertical scroll position, plus the optional margin, would
              // put the target element at the specified limit, set the target
              // element to absolute.
              if (base.options.minWidth && $(window).width() < base.options.minWidth) {
                  if (!isUnfixed() || !wasReset) {
                      postPosition();
                      target.trigger('preUnfixed.ScrollToFixed');
                      setUnfixed();
                      target.trigger('unfixed.ScrollToFixed');
                  }
              } else if (base.options.maxWidth && $(window).width() > base.options.maxWidth) {
                  if (!isUnfixed() || !wasReset) {
                      postPosition();
                      target.trigger('preUnfixed.ScrollToFixed');
                      setUnfixed();
                      target.trigger('unfixed.ScrollToFixed');
                  }
              } else if (base.options.bottom == -1) {
                  // If the vertical scroll position, plus the optional margin, would
                  // put the target element at the specified limit, set the target
                  // element to absolute.
                  if (limit > 0 && y >= limit - getMarginTop()) {
                      if (!wasUnfixed && (!isAbsolute() || !wasReset)) {
                          postPosition();
                          target.trigger('preAbsolute.ScrollToFixed');
                          setAbsolute();
                          target.trigger('unfixed.ScrollToFixed');
                      }
                  // If the vertical scroll position, plus the optional margin, would
                  // put the target element above the top of the page, set the target
                  // element to fixed.
                  } else if (y >= offsetTop - getMarginTop()) {
                      if (!isFixed() || !wasReset) {
                          postPosition();
                          target.trigger('preFixed.ScrollToFixed');
  
                          // Set the target element to fixed.
                          setFixed();
  
                          // Reset the last offset left because we just went fixed.
                          lastOffsetLeft = -1;
  
                          target.trigger('fixed.ScrollToFixed');
                      }
                      // If the page has been scrolled horizontally as well, move the
                      // target element accordingly.
                      setLeft(x);
                  } else {
                      // Set the target element to unfixed, placing it where it was
                      // before.
                      if (!isUnfixed() || !wasReset) {
                          postPosition();
                          target.trigger('preUnfixed.ScrollToFixed');
                          setUnfixed();
                          target.trigger('unfixed.ScrollToFixed');
                      }
                  }
              } else {
                  if (limit > 0) {
                      if (y + $(window).height() - target.outerHeight(true) >= limit - (getMarginTop() || -getBottom())) {
                          if (isFixed()) {
                              postPosition();
                              target.trigger('preUnfixed.ScrollToFixed');
  
                              if (originalPosition === 'absolute') {
                                  setAbsolute();
                              } else {
                                  setUnfixed();
                              }
  
                              target.trigger('unfixed.ScrollToFixed');
                          }
                      } else {
                          if (!isFixed()) {
                              postPosition();
                              target.trigger('preFixed.ScrollToFixed');
                              setFixed();
                          }
                          setLeft(x);
                          target.trigger('fixed.ScrollToFixed');
                      }
                  } else {
                      setLeft(x);
                  }
              }
          }