Prevent bugs in Accordion, Magellan, OffCanvas, Reveal, Sticky, Tabs and trigger utilities when the component is dynamically added because the window `load` event they rely on would never be triggered.
Note: In addition to the bug fix, the following behaviors are changed:
* Accordion now smoothly scroll to the opened pane when the hash is changed
'use strict';
import $ from 'jquery';
+import { onLoad, GetYoDigits } from './foundation.util.core';
import { Keyboard } from './foundation.util.keyboard';
-import { GetYoDigits } from './foundation.util.core';
import { Plugin } from './foundation.plugin';
/**
//roll up a little to show the titles
if (this.options.deepLinkSmudge) {
var _this = this;
- $(window).on('load', function() {
+ onLoad(function() {
var offset = _this.$element.offset();
$('html, body').animate({ scrollTop: offset.top }, _this.options.deepLinkSmudgeDelay);
});
import $ from 'jquery';
-import { GetYoDigits } from './foundation.util.core';
+import { onLoad, GetYoDigits } from './foundation.util.core';
import { Plugin } from './foundation.plugin';
import { SmoothScroll } from './foundation.smoothScroll';
duration: _this.options.animationDuration,
easing: _this.options.animationEasing
};
+
$(window).one('load', function(){
if(_this.options.deepLinking){
if(location.hash){
_this._updateActive();
});
- if (document.readyState === "complete") {
+ onLoad(function () {
_this.$element.on({
'resizeme.zf.trigger': _this.reflow.bind(_this),
'scrollme.zf.trigger': _this._updateActive.bind(_this)
- }).on('click.zf.magellan', 'a[href^="#"]', function(e) {
+ }).on('click.zf.magellan', 'a[href^="#"]', function (e) {
e.preventDefault();
var arrival = _this.getAttribute('href');
_this.scrollToLoc(arrival);
});
- } else {
- $(window).one('load', function(){
- _this.$element.on({
- 'resizeme.zf.trigger': _this.reflow.bind(_this),
- 'scrollme.zf.trigger': _this._updateActive.bind(_this)
- }).on('click.zf.magellan', 'a[href^="#"]', function(e) {
- e.preventDefault();
- var arrival = _this.getAttribute('href');
- _this.scrollToLoc(arrival);
- });
- });
- }
-
+ });
+
this._deepLinkScroll = function(e) {
if(_this.options.deepLinking) {
_this.scrollToLoc(window.location.hash);
'use strict';
import $ from 'jquery';
+import { onLoad, transitionend, RegExpEscape } from './foundation.util.core';
import { Keyboard } from './foundation.util.keyboard';
import { MediaQuery } from './foundation.util.mediaQuery';
-import { transitionend, RegExpEscape } from './foundation.util.core';
import { Plugin } from './foundation.plugin';
import { Triggers } from './foundation.util.triggers';
_setMQChecker() {
var _this = this;
- $(window).on('changed.zf.mediaquery', function() {
+ onLoad(function () {
if (MediaQuery.atLeast(_this.options.revealOn)) {
_this.reveal(true);
- } else {
- _this.reveal(false);
}
- }).one('load.zf.offCanvas', function() {
+ });
+
+ $(window).on('changed.zf.mediaquery', function () {
if (MediaQuery.atLeast(_this.options.revealOn)) {
_this.reveal(true);
+ } else {
+ _this.reveal(false);
}
});
}
'use strict';
import $ from 'jquery';
+import { onLoad } from './foundation.util.core';
import { Keyboard } from './foundation.util.keyboard';
import { MediaQuery } from './foundation.util.mediaQuery';
import { Motion } from './foundation.util.motion';
}
this._events();
if (this.options.deepLink && window.location.hash === ( `#${this.id}`)) {
- $(window).one('load.zf.reveal', this.open.bind(this));
+ onLoad(() => this.open());
}
}
'use strict';
import $ from 'jquery';
-import { GetYoDigits } from './foundation.util.core';
+import { onLoad, GetYoDigits } from './foundation.util.core';
import { MediaQuery } from './foundation.util.mediaQuery';
import { Plugin } from './foundation.plugin';
import { Triggers } from './foundation.util.triggers';
this.scrollCount = this.options.checkEvery;
this.isStuck = false;
- $(window).one('load.zf.sticky', function(){
+ onLoad(function () {
//We calculate the container height to have correct values for anchor points offset calculation.
_this.containerHeight = _this.$element.css("display") == "none" ? 0 : _this.$element[0].getBoundingClientRect().height;
_this.$container.css('height', _this.containerHeight);
_this.elemHeight = _this.containerHeight;
- if(_this.options.anchor !== ''){
+ if (_this.options.anchor !== '') {
_this.$anchor = $('#' + _this.options.anchor);
- }else{
+ } else {
_this._parsePoints();
}
- _this._setSizes(function(){
+ _this._setSizes(function () {
var scroll = window.pageYOffset;
_this._calc(false, scroll);
//Unstick the element will ensure that proper classes are set.
'use strict';
import $ from 'jquery';
+import { onLoad } from './foundation.util.core';
import { Keyboard } from './foundation.util.keyboard';
import { onImagesLoaded } from './foundation.util.imageLoader';
import { Plugin } from './foundation.plugin';
}
if(isActive && _this.options.autoFocus){
- $(window).on('load', function() {
+ onLoad(function() {
$('html, body').animate({ scrollTop: $elem.offset().top }, _this.options.deepLinkSmudgeDelay, () => {
$link.focus();
});
'use strict';
import $ from 'jquery';
+import { onLoad } from './foundation.util.core';
import { Motion } from './foundation.util.motion';
const MutationObserver = (function () {
if (typeof($.triggersInitialized) === 'undefined') {
let $document = $(document);
- if(document.readyState === "complete") {
+ onLoad(function () {
Triggers.Initializers.addSimpleListeners();
Triggers.Initializers.addGlobalListeners();
- } else {
- $(window).on('load', () => {
- Triggers.Initializers.addSimpleListeners();
- Triggers.Initializers.addGlobalListeners();
- });
- }
-
+ });
$.triggersInitialized = true;
}