From 7b171d8ccd4368647a286c92a29ab49356329ab7 Mon Sep 17 00:00:00 2001 From: Chris Oyler Date: Mon, 25 Jan 2016 11:13:24 -0800 Subject: [PATCH] fixes PART of #7969, wraps section of initialization function in a window.onLoad event, prevents most of the issues of incorrect sticky positions due to calculations performed before images/dom content was fully loaded. still some cross-browser issues due to the way scroll/resize events are fired. safari can diaf --- js/foundation.sticky.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/js/foundation.sticky.js b/js/foundation.sticky.js index ebd29b0cb..54655d77a 100644 --- a/js/foundation.sticky.js +++ b/js/foundation.sticky.js @@ -112,17 +112,18 @@ this.scrollCount = this.options.checkEvery; this.isStuck = false; + $(window).one('load.zf.sticky', function(){ + if(_this.options.anchor !== ''){ + _this.$anchor = $('#' + _this.options.anchor); + }else{ + _this._parsePoints(); + } - if(this.options.anchor !== ''){ - this.$anchor = $('#' + this.options.anchor); - }else{ - this._parsePoints(); - } - - this._setSizes(function(){ - _this._calc(false); + _this._setSizes(function(){ + _this._calc(false); + }); + _this._events(id.split('-').reverse().join('-')); }); - this._events(id.split('-').reverse().join('-')); }; /** * If using multiple elements as anchors, calculates the top and bottom pixel values the sticky thing should stick and unstick on. -- 2.47.2