define([ 'jquery', 'jquery-ui-modules/widget', 'jquery-ui-modules/core', 'jquery-ui-modules/effect', 'owl.carousel', ], function ($) { 'use strict'; var animation_text_space = 0; $.widget('mage.OxBannerSlider', { options: { // OxBannerSlider autoScroll: 0, slideWidth: 0, slideHeight: 0, customNav: true, // Owl.carousel dots: false, rewind: false, items: 1, slideBy: 1, lazyLoad: true, responsive: { 0: { items: 1, }, }, nav: false, observerLoad: !(window.hasOwnProperty('OX_OWL_OBS_DISABLE') ? OX_OWL_OBS_DISABLE : false) }, _create: function () { this.options.responsiveBaseElement = this.element.parent(); this.options.autoplayTimeout = parseInt(this.options.autoScroll) * 1000; this.options.autoplay = 0 < this.options.autoplayTimeout; this.options.autoplayHoverPause = this.options.autoplay; if (this.options.observerLoad) { this._loadObserver(); } else { this._loadOwl(); } }, _loadObserver: function () { let _self = this; if (window.IntersectionObserver) { let observer = new IntersectionObserver(function (entries, observer) { Array.prototype.forEach.call(entries, function (entry) { if (entry.isIntersecting) { _self._loadOwl.call(_self); observer.unobserve(entry.target); } }); }, { root: null, rootMargin: "0px", threshold: [0] }); this.element.each(function (i, el) { observer.observe(el); }); } else { let debouncer = function (func) { var timeoutID; return function () { var scope = this, args = arguments; clearTimeout(timeoutID); timeoutID = setTimeout(function () { func.apply(scope, Array.prototype.slice.call(args)); }, 200); } }; $(window).one('scroll resize', debouncer(function () { let height = window.visualViewport ? window.visualViewport.height : window.innerHeight; this.element.each(function (i, el) { let bounding = el.getBoundingClientRect(); if (bounding.top != bounding.bottom && 0 < bounding.bottom && height > bounding.top) { _self._loadOwl.call(_self); } }) })); } }, _loadOwl: function () { var options = this._createOptions(); this.element.owlCarousel(options); this.arrows(); }, _createOptions: function () { var _self = this; var options = { onInitialize: function () { var $carousel = this.$element, $items = $carousel.find('.ox-banner__slide'), $text_container = $carousel.find('.ox-banner__text-container'), $text = $text_container.find('.text'), $link = $text_container.find('.link'); this.$element.data('textSize', parseInt($text.css('font-size'), 10)); this.$element.data('textLineHeight', parseInt($text.css('line-height'), 10)); this.$element.data('linkSize', parseInt($link.css('font-size'), 12)); $text_container.show(); $text.wrap('
'); $link.wrap('