]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fixes #7927, but points out other issues needing resolution. Breaks out scrolling...
authorChris Oyler <chris@zurb.com>
Wed, 20 Jan 2016 19:12:21 +0000 (11:12 -0800)
committerChris Oyler <chris@zurb.com>
Wed, 20 Jan 2016 19:12:21 +0000 (11:12 -0800)
js/foundation.magellan.js

index 272e307afc203497e99d73cdc1eed42c70838f91..f6ba9d7b0e018ea60a1ef48de1d965134533713a 100644 (file)
           duration: _this.options.animationDuration,
           easing:   _this.options.animationEasing
         };
-
     $(window).one('load', function(){
+      if(_this.options.deepLinking){
+        if(location.hash){
+          _this.scrollToLoc(location.hash);
+        }
+      }
       _this.calcPoints();
       _this._updateActive();
     });
       'scrollme.zf.trigger': this._updateActive.bind(this)
     }).on('click.zf.magellan', 'a[href^="#"]', function(e) {
         e.preventDefault();
-        var arrival   = this.getAttribute('href'),
-            scrollPos = $(arrival).offset().top - _this.options.threshold / 2 - _this.options.barOffset;
-
-        // requestAnimationFrame is disabled for this plugin currently
-        // Foundation.Move(_this.options.animationDuration, $body, function(){
-          $body.stop(true).animate({
-            scrollTop: scrollPos
-          }, opts);
-        });
-      // });
+        var arrival   = this.getAttribute('href');
+        _this.scrollToLoc(arrival);
+    });
+  };
+  /**
+   * Function to scroll to a given location on the page.
+   * @param {String} loc - a properly formatted jQuery id selector.
+   * @example '#foo'
+   * @function
+   */
+  Magellan.prototype.scrollToLoc = function(loc){
+    var scrollPos = $(loc).offset().top - this.options.threshold / 2 - this.options.barOffset;
+
+    $(document.body).stop(true).animate({
+        scrollTop: scrollPos
+      },
+      {
+        duration: this.options.animationDuration,
+        easiing: this.options.animationEasing
+     });
   };
   /**
    * Calls necessary functions to update Magellan upon DOM change