Q2W3 Fixed Widget - Version 6.0.3

Version Description

  • Improvement: Check lazy elements and stop elements for changing their size and recalculate fixed position
  • Improvement: Lower check interval from 1000 to 500 ms
Download this release

Release Info

Developer webzunft
Plugin Icon 128x128 Q2W3 Fixed Widget
Version 6.0.3
Comparing to
See all releases

Code changes from version 6.0.2 to 6.0.3

Files changed (4) hide show
  1. js/frontend.js +121 -37
  2. js/frontend.min.js +1 -1
  3. q2w3-fixed-widget.php +2 -2
  4. readme.txt +10 -5
js/frontend.js CHANGED
@@ -126,7 +126,7 @@ var get_sibilings_offset = function (next, need_to_calc_el_offset, el, offset) {
126
  return get_sibilings_offset(next, need_to_calc_el_offset, next(el), offset);
127
  }
128
  var _a = getComputedStyle(el), marginTop = _a.marginTop, marginBottom = _a.marginBottom;
129
- return get_sibilings_offset(next, need_to_calc_el_offset, next(el), offset + el.offsetHeight + parseInt(marginTop || '0') + parseInt(marginBottom || '0'));
130
  };
131
 
132
  /**
@@ -185,6 +185,33 @@ function findWithProperty(el, predicate) {
185
  return findWithProperty(el.parentElement, predicate);
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  var PositionWidget = /** @class */ (function (_super) {
189
  __extends(PositionWidget, _super);
190
  function PositionWidget() {
@@ -192,6 +219,7 @@ var PositionWidget = /** @class */ (function (_super) {
192
  _this.bottom_offset = 0;
193
  _this.top_margin = 0;
194
  _this.borderBox = 0; /** cleintHeight+ top & bottom margins */
 
195
  /** Top offset of StopWidget */
196
  _this.max_top_offset = 0;
197
  _this.bottom_margin = 0;
@@ -205,6 +233,7 @@ var PositionWidget = /** @class */ (function (_super) {
205
  return _this;
206
  }
207
  PositionWidget.prototype.mount = function (user_margins) {
 
208
  _super.prototype.mount.call(this, user_margins);
209
  if (!this.el || !this.el.parentElement) {
210
  return;
@@ -214,17 +243,21 @@ var PositionWidget = /** @class */ (function (_super) {
214
  this.bottom_margin = parseInt(marginBottom);
215
  this.top_margin = parseInt(marginTop);
216
  this.bottom_offset = this.get_total_bottom_offset(user_margins);
217
- this.borderBox = this.el.clientHeight + this.top_margin + this.bottom_margin;
 
 
 
 
 
 
 
 
218
  };
219
  PositionWidget.prototype.setMaxOffset = function (max_top_offset) {
220
  this.max_top_offset = max_top_offset;
221
  };
222
  PositionWidget.prototype.render = function () {
223
- if (!this.el || !this.el.parentElement) {
224
- return;
225
- }
226
- var scrollTop = scrollY;
227
- this.onScroll(scrollTop);
228
  };
229
  PositionWidget.from = function (root) {
230
  return _super.from.call(this, root, FixedWidgetClassName);
@@ -256,6 +289,7 @@ var FixedWidget = /** @class */ (function (_super) {
256
  return _this;
257
  }
258
  FixedWidget.prototype.mount = function (margins) {
 
259
  _super.prototype.mount.call(this, margins);
260
  if (!this.el) {
261
  return;
@@ -267,13 +301,18 @@ var FixedWidget = /** @class */ (function (_super) {
267
  + this.bottom_offset;
268
  this.store_style(getComputedStyle(this.el));
269
  this.clone();
 
 
 
 
270
  };
271
  FixedWidget.prototype.setMaxOffset = function (max_top_offset) {
272
  /** StopWidget can limit top offset if it is placed only after widget */
273
- if (max_top_offset < this.root_offset) {
274
  return;
275
  }
276
  this.max_top_offset = max_top_offset;
 
277
  };
278
  FixedWidget.prototype.clone = function () {
279
  var _this = this;
@@ -311,12 +350,6 @@ var FixedWidget = /** @class */ (function (_super) {
311
  if (!this.el) {
312
  return;
313
  }
314
- /**
315
- * Recalculate relative block's height on scroll because it could change
316
- */
317
- var block_height = Math.max(this.el.clientHeight, this.el.scrollHeight, this.el.getBoundingClientRect().height);
318
- this.borderBox = block_height + this.top_margin + this.bottom_margin;
319
- this.relative_top = this.max_top_offset - block_height - this.paddings;
320
  var need_to_fix = scrollTop > this.root_offset - this.top_offset;
321
  var limited_by_stop_element = this.max_top_offset !== 0 && scrollTop > this.relative_top;
322
  var top = limited_by_stop_element ? this.relative_top - scrollTop + this.top_offset : this.top_offset;
@@ -422,6 +455,14 @@ var StopWidget = /** @class */ (function (_super) {
422
  _this.el.classList.add(StopWidgetClassName);
423
  return _this;
424
  }
 
 
 
 
 
 
 
 
425
  StopWidget.new = function (selector) {
426
  return new StopWidget(document.querySelector(selector));
427
  };
@@ -437,18 +478,26 @@ var StopWidget = /** @class */ (function (_super) {
437
 
438
  var Sidebar = /** @class */ (function () {
439
  function Sidebar(el, margins, use_sticky_position) {
 
440
  if (use_sticky_position === void 0) { use_sticky_position = true; }
441
  this.el = el;
442
  this.margins = margins;
443
- this.use_sticky_position = use_sticky_position;
444
  this.widgets = [];
445
  this.stop_widgets = [];
 
 
 
 
 
 
 
446
  var isDeprecatedFloatMarkup = !!findWithProperty(this.el, function (style) { return style.float !== 'none'; });
447
  isDeprecatedFloatMarkup && console.log('Fixed Widget: fallback to position sticky');
448
- var WidgetContructor = isDeprecatedFloatMarkup || !use_sticky_position ? FixedWidget : StickyWidget;
 
449
  this.stop_widgets = StopWidget.from(this.el);
450
  this.widgets = WidgetContructor.from(this.el);
451
- if (!use_sticky_position) {
452
  return;
453
  }
454
  this.el.style.position = 'relative';
@@ -463,17 +512,34 @@ var Sidebar = /** @class */ (function () {
463
  this.widgets.forEach(function (widget) { widget.mount(_this.margins); });
464
  };
465
  Sidebar.prototype.setMaxOffset = function (common_stop_widgets) {
 
466
  var stop_widgets = this.stop_widgets.length != 0 ? this.stop_widgets : common_stop_widgets;
467
- var max_top_offset = stop_widgets.length !== 0 ? Math.min.apply(Math, stop_widgets.map(this.use_sticky_position ?
468
- function (w) { return w.top_offset; } :
469
- function (w) { return w.root_offset; })) :
470
- 0;
471
- this.widgets.forEach(function (widget, i) { widget.setMaxOffset(max_top_offset); });
 
 
 
 
 
 
 
 
 
 
 
472
  };
473
  Sidebar.prototype.render = function () {
474
- this.widgets.forEach(function (widget) { return widget.render(); });
475
- };
476
- Sidebar.prototype.isFloatMarkup = function () {
 
 
 
 
 
477
  };
478
  return Sidebar;
479
  }());
@@ -483,7 +549,10 @@ var Sidebars = /** @class */ (function () {
483
  var _this = this;
484
  this.data = [];
485
  this.render = function () {
486
- _this.data.forEach(function (sidebar) { sidebar.render(); });
 
 
 
487
  };
488
  var use_sticky_position = typeof options.use_sticky_position === 'undefined' || options.use_sticky_position;
489
  this.data = Array.from(new Set(elements.map(function (widget) { return widget.parentElement; })))
@@ -492,12 +561,21 @@ var Sidebars = /** @class */ (function () {
492
  }
493
  Sidebars.prototype.mount = function () {
494
  this.data.forEach(function (sidebar) { sidebar.mount(); });
495
- var common_stop_widgets = this.getCommonStopElements();
496
- this.data.forEach(function (sidebar) { sidebar.setMaxOffset(common_stop_widgets); });
497
  };
498
- Sidebars.prototype.getCommonStopElements = function () {
499
- return this.data
500
- .filter(function (sidebar) { return sidebar.widgets.length === 0; })
 
 
 
 
 
 
 
 
 
 
501
  .map(function (sidebar) { return sidebar.stop_widgets; })
502
  .reduce(function (all, widgets) { return all.concat(widgets); }, []);
503
  };
@@ -507,7 +585,7 @@ var Sidebars = /** @class */ (function () {
507
  .queryAllWidgetsContainers(FixedWidgetClassName) // widgets by classNames from editor's plugin
508
  .concat(queryElements(compatabilty_FW_v5(options.widgets))) // widgets from option's custom selectors
509
  ));
510
- var stopWidgetsSelectors = compatabilty_FW_v5(splitSelectors(options.stop_elements_selectors));
511
  var stopWidgetsContainers = Array.from(new Set(// use Set to remove duplicates
512
  Widget
513
  .queryAllWidgetsContainers(StopWidgetClassName) // widgets by classNames from editor's plugin;
@@ -519,26 +597,32 @@ var Sidebars = /** @class */ (function () {
519
  });
520
  fixedWidgetsContainers.forEach(function (c) { c.classList.add(FixedWidgetClassName); });
521
  stopWidgetsUniqContainers.forEach(function (c) { c.classList.add(StopWidgetClassName); });
522
- var sidebars = new Sidebars(fixedWidgetsContainers.concat(stopWidgetsUniqContainers), options);
523
- sidebars.mount();
524
- document.addEventListener('scroll', sidebars.render);
525
  };
526
  return Sidebars;
527
  }());
528
 
 
529
  var initPlugin = function (options) {
530
  if (options === void 0) { options = []; }
531
- Sidebars.new(options.reduce(function (prev, cur) { return (__assign(__assign(__assign({}, prev), cur), { widgets: prev.widgets.concat(cur.widgets || []) })); }, { widgets: [] }));
 
 
 
 
 
 
532
  };
533
 
534
  window.addEventListener('load', onDocumentLoaded);
535
  document.readyState === "complete" && onDocumentLoaded();
 
536
  function onDocumentLoaded() {
537
  var admin_panel = document.querySelector('#wpadminbar');
538
  // @ts-ignore
539
  var user_options = window['q2w3_sidebar_options'] || [{}];
540
  var options = user_options.map(function (option) {
541
- option.margin_top = (option.margin_top || 0) + ((admin_panel === null || admin_panel === void 0 ? void 0 : admin_panel.clientHeight) || 0);
542
  return option;
543
  });
544
  if (options.some(function (option) {
126
  return get_sibilings_offset(next, need_to_calc_el_offset, next(el), offset);
127
  }
128
  var _a = getComputedStyle(el), marginTop = _a.marginTop, marginBottom = _a.marginBottom;
129
+ return get_sibilings_offset(next, need_to_calc_el_offset, next(el), offset + el.getBoundingClientRect().height + parseInt(marginTop || '0') + parseInt(marginBottom || '0'));
130
  };
131
 
132
  /**
185
  return findWithProperty(el.parentElement, predicate);
186
  }
187
 
188
+ var reactive = function (getter, interval) {
189
+ if (interval === void 0) { interval = 300; }
190
+ var subs = [];
191
+ var v = getter();
192
+ setInterval(function () {
193
+ if (subs.length === 0) {
194
+ return;
195
+ }
196
+ var new_v = getter();
197
+ if (v !== new_v) {
198
+ v = new_v;
199
+ for (var _i = 0, subs_1 = subs; _i < subs_1.length; _i++) {
200
+ var update = subs_1[_i];
201
+ update(new_v);
202
+ }
203
+ }
204
+ }, interval);
205
+ return {
206
+ get val() {
207
+ return v;
208
+ },
209
+ on_change: function (update) {
210
+ subs.push(update);
211
+ }
212
+ };
213
+ };
214
+
215
  var PositionWidget = /** @class */ (function (_super) {
216
  __extends(PositionWidget, _super);
217
  function PositionWidget() {
219
  _this.bottom_offset = 0;
220
  _this.top_margin = 0;
221
  _this.borderBox = 0; /** cleintHeight+ top & bottom margins */
222
+ _this.block_height = reactive(function () { return 0; });
223
  /** Top offset of StopWidget */
224
  _this.max_top_offset = 0;
225
  _this.bottom_margin = 0;
233
  return _this;
234
  }
235
  PositionWidget.prototype.mount = function (user_margins) {
236
+ var _this = this;
237
  _super.prototype.mount.call(this, user_margins);
238
  if (!this.el || !this.el.parentElement) {
239
  return;
243
  this.bottom_margin = parseInt(marginBottom);
244
  this.top_margin = parseInt(marginTop);
245
  this.bottom_offset = this.get_total_bottom_offset(user_margins);
246
+ this.block_height = reactive(function () {
247
+ if (!_this.el) {
248
+ return 0;
249
+ }
250
+ return Math.round(Math.max(_this.el.clientHeight, _this.el.scrollHeight, _this.el.getBoundingClientRect().height));
251
+ });
252
+ this.block_height.on_change(function (block_height) {
253
+ _this.borderBox = block_height + _this.top_margin + _this.bottom_margin;
254
+ });
255
  };
256
  PositionWidget.prototype.setMaxOffset = function (max_top_offset) {
257
  this.max_top_offset = max_top_offset;
258
  };
259
  PositionWidget.prototype.render = function () {
260
+ this.onScroll(scrollY);
 
 
 
 
261
  };
262
  PositionWidget.from = function (root) {
263
  return _super.from.call(this, root, FixedWidgetClassName);
289
  return _this;
290
  }
291
  FixedWidget.prototype.mount = function (margins) {
292
+ var _this = this;
293
  _super.prototype.mount.call(this, margins);
294
  if (!this.el) {
295
  return;
301
  + this.bottom_offset;
302
  this.store_style(getComputedStyle(this.el));
303
  this.clone();
304
+ this.block_height.on_change(function (block_height) {
305
+ _this.relative_top = _this.max_top_offset - block_height - _this.paddings;
306
+ _this.init_style.height = "".concat(block_height, "px");
307
+ });
308
  };
309
  FixedWidget.prototype.setMaxOffset = function (max_top_offset) {
310
  /** StopWidget can limit top offset if it is placed only after widget */
311
+ if (max_top_offset < this.root_offset || this.max_top_offset === max_top_offset) {
312
  return;
313
  }
314
  this.max_top_offset = max_top_offset;
315
+ this.relative_top = this.max_top_offset - this.block_height.val - this.paddings;
316
  };
317
  FixedWidget.prototype.clone = function () {
318
  var _this = this;
350
  if (!this.el) {
351
  return;
352
  }
 
 
 
 
 
 
353
  var need_to_fix = scrollTop > this.root_offset - this.top_offset;
354
  var limited_by_stop_element = this.max_top_offset !== 0 && scrollTop > this.relative_top;
355
  var top = limited_by_stop_element ? this.relative_top - scrollTop + this.top_offset : this.top_offset;
455
  _this.el.classList.add(StopWidgetClassName);
456
  return _this;
457
  }
458
+ StopWidget.prototype.mount = function (user_margins) {
459
+ var _this = this;
460
+ _super.prototype.mount.call(this, user_margins);
461
+ reactive(function () { return Math.round(scrollY + (_this.el ? _this.el.getBoundingClientRect().top : 0)); })
462
+ .on_change(function (root_offset) {
463
+ _this.root_offset = root_offset;
464
+ });
465
+ };
466
  StopWidget.new = function (selector) {
467
  return new StopWidget(document.querySelector(selector));
468
  };
478
 
479
  var Sidebar = /** @class */ (function () {
480
  function Sidebar(el, margins, use_sticky_position) {
481
+ var _this = this;
482
  if (use_sticky_position === void 0) { use_sticky_position = true; }
483
  this.el = el;
484
  this.margins = margins;
 
485
  this.widgets = [];
486
  this.stop_widgets = [];
487
+ this.isSticky = true;
488
+ this.setWidgetsMaxOffset = function (max_offset) {
489
+ for (var _i = 0, _a = _this.widgets; _i < _a.length; _i++) {
490
+ var widget = _a[_i];
491
+ widget.setMaxOffset(max_offset);
492
+ }
493
+ };
494
  var isDeprecatedFloatMarkup = !!findWithProperty(this.el, function (style) { return style.float !== 'none'; });
495
  isDeprecatedFloatMarkup && console.log('Fixed Widget: fallback to position sticky');
496
+ this.isSticky = !isDeprecatedFloatMarkup && use_sticky_position;
497
+ var WidgetContructor = this.isSticky ? StickyWidget : FixedWidget;
498
  this.stop_widgets = StopWidget.from(this.el);
499
  this.widgets = WidgetContructor.from(this.el);
500
+ if (!this.isSticky) {
501
  return;
502
  }
503
  this.el.style.position = 'relative';
512
  this.widgets.forEach(function (widget) { widget.mount(_this.margins); });
513
  };
514
  Sidebar.prototype.setMaxOffset = function (common_stop_widgets) {
515
+ var _this = this;
516
  var stop_widgets = this.stop_widgets.length != 0 ? this.stop_widgets : common_stop_widgets;
517
+ if (stop_widgets.length === 0) {
518
+ return;
519
+ }
520
+ var max_top_offset = reactive(function () {
521
+ var min_offset = _this.isSticky ? stop_widgets[0].top_offset : stop_widgets[0].root_offset;
522
+ for (var _i = 0, stop_widgets_1 = stop_widgets; _i < stop_widgets_1.length; _i++) {
523
+ var widget = stop_widgets_1[_i];
524
+ var offset = _this.isSticky ? widget.top_offset : widget.root_offset;
525
+ if (min_offset > offset) {
526
+ min_offset = offset;
527
+ }
528
+ }
529
+ return Math.round(min_offset);
530
+ });
531
+ max_top_offset.on_change(this.setWidgetsMaxOffset);
532
+ this.setWidgetsMaxOffset(max_top_offset.val);
533
  };
534
  Sidebar.prototype.render = function () {
535
+ for (var _i = 0, _a = this.stop_widgets; _i < _a.length; _i++) {
536
+ var stop_widget = _a[_i];
537
+ stop_widget.render();
538
+ }
539
+ for (var _b = 0, _c = this.widgets; _b < _c.length; _b++) {
540
+ var widget = _c[_b];
541
+ widget.render();
542
+ }
543
  };
544
  return Sidebar;
545
  }());
549
  var _this = this;
550
  this.data = [];
551
  this.render = function () {
552
+ for (var _i = 0, _a = _this.data; _i < _a.length; _i++) {
553
+ var sidebar = _a[_i];
554
+ sidebar.render();
555
+ }
556
  };
557
  var use_sticky_position = typeof options.use_sticky_position === 'undefined' || options.use_sticky_position;
558
  this.data = Array.from(new Set(elements.map(function (widget) { return widget.parentElement; })))
561
  }
562
  Sidebars.prototype.mount = function () {
563
  this.data.forEach(function (sidebar) { sidebar.mount(); });
564
+ this.setMaxOffset();
 
565
  };
566
+ Sidebars.prototype.setMaxOffset = function () {
567
+ var general_stop_widgets = this.getGeneralStopElements();
568
+ for (var _i = 0, _a = this.data; _i < _a.length; _i++) {
569
+ var sidebar = _a[_i];
570
+ sidebar.setMaxOffset(general_stop_widgets);
571
+ }
572
+ };
573
+ Sidebars.prototype.getGeneralStopElements = function () {
574
+ return this.data.filter(function (sidebar) {
575
+ return sidebar.isSticky ?
576
+ sidebar.widgets.length === 0 : /** for sticky widgets only alone stopElements are general */
577
+ true;
578
+ } /** all stop elements are general for fixed widgets */)
579
  .map(function (sidebar) { return sidebar.stop_widgets; })
580
  .reduce(function (all, widgets) { return all.concat(widgets); }, []);
581
  };
585
  .queryAllWidgetsContainers(FixedWidgetClassName) // widgets by classNames from editor's plugin
586
  .concat(queryElements(compatabilty_FW_v5(options.widgets))) // widgets from option's custom selectors
587
  ));
588
+ var stopWidgetsSelectors = compatabilty_FW_v5(splitSelectors(options.stop_elements_selectors || options.stop_id));
589
  var stopWidgetsContainers = Array.from(new Set(// use Set to remove duplicates
590
  Widget
591
  .queryAllWidgetsContainers(StopWidgetClassName) // widgets by classNames from editor's plugin;
597
  });
598
  fixedWidgetsContainers.forEach(function (c) { c.classList.add(FixedWidgetClassName); });
599
  stopWidgetsUniqContainers.forEach(function (c) { c.classList.add(StopWidgetClassName); });
600
+ return new Sidebars(fixedWidgetsContainers.concat(stopWidgetsUniqContainers), options);
 
 
601
  };
602
  return Sidebars;
603
  }());
604
 
605
+ var sidebars;
606
  var initPlugin = function (options) {
607
  if (options === void 0) { options = []; }
608
+ if (sidebars) {
609
+ sidebars.render();
610
+ return;
611
+ }
612
+ sidebars = Sidebars.new(options.reduce(function (prev, cur) { return (__assign(__assign(__assign({}, prev), cur), { widgets: prev.widgets.concat(cur.widgets || []) })); }, { widgets: [] }));
613
+ document.addEventListener('scroll', sidebars.render);
614
+ sidebars.mount();
615
  };
616
 
617
  window.addEventListener('load', onDocumentLoaded);
618
  document.readyState === "complete" && onDocumentLoaded();
619
+ onDocumentLoaded();
620
  function onDocumentLoaded() {
621
  var admin_panel = document.querySelector('#wpadminbar');
622
  // @ts-ignore
623
  var user_options = window['q2w3_sidebar_options'] || [{}];
624
  var options = user_options.map(function (option) {
625
+ option.margin_top = (option.margin_top || 0) + (admin_panel && admin_panel.clientHeight || 0);
626
  return option;
627
  });
628
  if (options.some(function (option) {
js/frontend.min.js CHANGED
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};function __extends(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t},__assign.apply(this,arguments)},StopWidgetClassName="FixedWidget__stop_widget",FixedWidgetClassName="FixedWidget__fixed_widget",Widget=function(){function Widget(el){this.el=el,this.top_offset=0,this.root_offset=0,this.need_to_calc_el_offset=function(_){return!1},this.prevSibling=function(el){return el&&el.previousElementSibling}}return Widget.prototype.render=function(){},Widget.prototype.mount=function(user_margins){void 0===user_margins&&(user_margins={}),this.el&&this.el.parentElement&&(this.top_offset=this.get_total_top_offset(user_margins),this.root_offset=scrollY+this.el.getBoundingClientRect().y)},Widget.prototype.getElement=function(){return this.el},Widget.prototype.toString=function(){var _a;return"".concat(null===(_a=this.el)||void 0===_a?void 0:_a.innerHTML)},Widget.prototype.get_total_top_offset=function(margins){return get_sibilings_offset(this.prevSibling,this.need_to_calc_el_offset,this.prevSibling(this.el),margins.margin_top)},Widget.queryAllWidgetsContainers=function(className){return[].concat(Array.from(document.querySelectorAll(".".concat(className))),Array.from(document.querySelectorAll("[data-fixed_widget=".concat(className)))).map((function(el){el.classList.remove(className),el.removeAttribute("data-fixed_widget");var container=getWidgetContainer(el);return container.classList.remove(FixedWidgetClassName),container.classList.remove(StopWidgetClassName),container}))},Widget.from=function(root,className){var _this=this,elements=[];try{elements=Array.from(root.querySelectorAll(":scope > .".concat(className)))}catch(_e){elements=Array.from(root.children).filter((function(e){return e.classList.contains(className)}))}return elements.filter((function(el){return null!==el})).map((function(e){return new _this(e)}))},Widget}(),getWidgetContainer=function(el){return el.parentElement&&(1===el.parentElement.childElementCount||el.parentElement.classList.toString().includes("wp-block-group")||el.parentElement.classList.toString().includes("wp-block-column")||el.parentElement.classList.contains("widget"))?getWidgetContainer(el.parentElement):el},get_sibilings_offset=function(next,need_to_calc_el_offset,el,offset){if(void 0===offset&&(offset=0),!el)return offset;if(!need_to_calc_el_offset(el))return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset);var _a=getComputedStyle(el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset+el.offsetHeight+parseInt(marginTop||"0")+parseInt(marginBottom||"0"))},compatabilty_FW_v5=function(selectors){return void 0===selectors&&(selectors=[]),selectors.some((function(s){return!/^[a-z]/i.test(s)}))?selectors:selectors.concat(selectors.map((function(s){return"#".concat(s)})))},queryElements=function(selectors){return void 0===selectors&&(selectors=[]),Array.from(selectors.map((function(selector){return Array.from(document.querySelectorAll(selector))}))).reduce((function(all,elements){return all.concat(elements)}),[]).filter((function(e){return e instanceof HTMLElement}))};function findWithProperty(el,predicate){return el&&el!==document.body?predicate(getComputedStyle(el))?el:findWithProperty(el.parentElement,predicate):null}var PositionWidget=function(_super){function PositionWidget(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.bottom_offset=0,_this.top_margin=0,_this.borderBox=0,_this.max_top_offset=0,_this.bottom_margin=0,_this.user_margins={},_this.prevSibling=function(el){return el&&!el.classList.contains(StopWidgetClassName)&&el.previousElementSibling||null},_this}return __extends(PositionWidget,_super),PositionWidget.prototype.mount=function(user_margins){if(_super.prototype.mount.call(this,user_margins),this.el&&this.el.parentElement){this.user_margins=user_margins;var _a=getComputedStyle(this.el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;this.bottom_margin=parseInt(marginBottom),this.top_margin=parseInt(marginTop),this.bottom_offset=this.get_total_bottom_offset(user_margins),this.borderBox=this.el.clientHeight+this.top_margin+this.bottom_margin}},PositionWidget.prototype.setMaxOffset=function(max_top_offset){this.max_top_offset=max_top_offset},PositionWidget.prototype.render=function(){if(this.el&&this.el.parentElement){var scrollTop=scrollY;this.onScroll(scrollTop)}},PositionWidget.from=function(root){return _super.from.call(this,root,FixedWidgetClassName)},PositionWidget.prototype.onScroll=function(_scrollTop){},PositionWidget.prototype.get_total_bottom_offset=function(margins){var next=function(el){return el&&!el.classList.contains(StopWidgetClassName)?el.nextElementSibling:null};return get_sibilings_offset(next,this.need_to_calc_el_offset,next(this.el),margins.margin_bottom)},PositionWidget}(Widget),FixedWidget=function(_super){function FixedWidget(el){var _this=_super.call(this,el)||this;return _this.is_pinned=!1,_this.relative_top=0,_this.paddings=0,_this.init_style={position:"static",marginTop:"",marginBottom:"",width:"",height:""},_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(FixedWidget,_super),FixedWidget.prototype.mount=function(margins){_super.prototype.mount.call(this,margins),this.el&&(this.paddings=this.top_offset+this.top_margin+this.bottom_margin+this.bottom_offset,this.store_style(getComputedStyle(this.el)),this.clone())},FixedWidget.prototype.setMaxOffset=function(max_top_offset){max_top_offset<this.root_offset||(this.max_top_offset=max_top_offset)},FixedWidget.prototype.clone=function(){var _this=this;if(this.el&&this.el.parentElement){for(var prop in this.clone_el=this.el.cloneNode(!1),this.clone_el.getAttributeNames().forEach((function(attr){_this.clone_el.removeAttribute(attr)})),this.init_style)this.clone_el.style[prop]=this.init_style[prop];this.clone_el.style.display="none",this.el.parentElement.insertBefore(this.clone_el,this.el)}},FixedWidget.prototype.store_style=function(style){this.init_style.position=style.position,this.init_style.marginTop=style.marginTop,this.init_style.marginBottom=style.marginBottom,this.init_style.width=style.width,this.init_style.height=style.height},FixedWidget.prototype.restore_style=function(style){this.is_pinned&&(this.is_pinned=!1,style.position=this.init_style.position,this.clone_el&&(this.clone_el.style.display="none"))},FixedWidget.prototype.onScroll=function(scrollTop){if(this.el){var block_height=Math.max(this.el.clientHeight,this.el.scrollHeight,this.el.getBoundingClientRect().height);this.borderBox=block_height+this.top_margin+this.bottom_margin,this.relative_top=this.max_top_offset-block_height-this.paddings;var need_to_fix=scrollTop>this.root_offset-this.top_offset,top=0!==this.max_top_offset&&scrollTop>this.relative_top?this.relative_top-scrollTop+this.top_offset:this.top_offset;need_to_fix?this.fix(top):this.restore_style(this.el.style)}},FixedWidget.prototype.fix=function(top){this.el&&(this.el.style.top="".concat(top,"px"),this.is_pinned||(this.is_pinned=!0,this.el.style.position="fixed",this.el.style.transition="transform 0.5s",this.el.style.width=this.init_style.width,this.el.style.height=this.init_style.height,this.clone_el&&(this.clone_el.style.display="block")))},FixedWidget.new=function(selector){return new FixedWidget(document.querySelector(selector))},FixedWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},FixedWidget}(PositionWidget),StickyWidget=function(_super){function StickyWidget(el){var _this=_super.call(this,el)||this;return _this.margins=0,_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(StickyWidget,_super),StickyWidget.prototype.mount=function(margins){_super.prototype.mount.call(this,margins),this.el&&this.el.parentElement&&(this.margins=this.el.parentElement.clientHeight-this.borderBox,this.el.style.position="sticky",this.el.style.position="-webkit-sticky",this.el.style.transition="transform 0s",this.el.style.boxSizing="border-box",this.el.style.top="".concat(this.top_offset,"px"))},StickyWidget.prototype.setMaxOffset=function(max_top_offset){this.el&&this.el.parentElement&&(max_top_offset<this.el.offsetTop||(this.max_top_offset=max_top_offset))},StickyWidget.prototype.onScroll=function(){if(this.el&&this.el.parentElement){var bottom_margin=this.max_top_offset?Math.min(this.max_top_offset-this.el.offsetTop-this.borderBox,this.margins-this.el.offsetTop):this.margins-this.el.offsetTop;bottom_margin>=this.bottom_offset?this.el.style.transform="translateY(0px)":this.el.style.transform="translateY(".concat(bottom_margin-this.bottom_offset,"px)")}},StickyWidget.new=function(selector){return new StickyWidget(document.querySelector(selector))},StickyWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},StickyWidget}(PositionWidget),StopWidget=function(_super){function StopWidget(el){var _this=_super.call(this,el)||this;return _this.need_to_calc_el_offset=function(){return!0},_this.el&&_this.el.parentElement?(_this.el.classList.add(StopWidgetClassName),_this):_this}return __extends(StopWidget,_super),StopWidget.new=function(selector){return new StopWidget(document.querySelector(selector))},StopWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(StopWidgetClassName)},StopWidget.from=function(root){return _super.from.call(this,root,StopWidgetClassName)},StopWidget}(Widget),Sidebar=function(){function Sidebar(el,margins,use_sticky_position){void 0===use_sticky_position&&(use_sticky_position=!0),this.el=el,this.margins=margins,this.use_sticky_position=use_sticky_position,this.widgets=[],this.stop_widgets=[];var isDeprecatedFloatMarkup=!!findWithProperty(this.el,(function(style){return"none"!==style.float}));isDeprecatedFloatMarkup&&console.log("Fixed Widget: fallback to position sticky");var WidgetContructor=isDeprecatedFloatMarkup||!use_sticky_position?FixedWidget:StickyWidget;this.stop_widgets=StopWidget.from(this.el),this.widgets=WidgetContructor.from(this.el),use_sticky_position&&(this.el.style.position="relative",0===this.stop_widgets.length&&(this.el.style.minHeight="100%"))}return Sidebar.prototype.mount=function(){var _this=this;this.stop_widgets.forEach((function(widget){widget.mount()})),this.widgets.forEach((function(widget){widget.mount(_this.margins)}))},Sidebar.prototype.setMaxOffset=function(common_stop_widgets){var stop_widgets=0!=this.stop_widgets.length?this.stop_widgets:common_stop_widgets,max_top_offset=0!==stop_widgets.length?Math.min.apply(Math,stop_widgets.map(this.use_sticky_position?function(w){return w.top_offset}:function(w){return w.root_offset})):0;this.widgets.forEach((function(widget,i){widget.setMaxOffset(max_top_offset)}))},Sidebar.prototype.render=function(){this.widgets.forEach((function(widget){return widget.render()}))},Sidebar.prototype.isFloatMarkup=function(){},Sidebar}(),Sidebars=function(){function Sidebars(elements,options){var _this=this;this.data=[],this.render=function(){_this.data.forEach((function(sidebar){sidebar.render()}))};var use_sticky_position=void 0===options.use_sticky_position||options.use_sticky_position;this.data=Array.from(new Set(elements.map((function(widget){return widget.parentElement})))).filter((function(sidebar_el){return null!==sidebar_el})).map((function(sidebar_el){return new Sidebar(sidebar_el,options,use_sticky_position)}))}return Sidebars.prototype.mount=function(){this.data.forEach((function(sidebar){sidebar.mount()}));var common_stop_widgets=this.getCommonStopElements();this.data.forEach((function(sidebar){sidebar.setMaxOffset(common_stop_widgets)}))},Sidebars.prototype.getCommonStopElements=function(){return this.data.filter((function(sidebar){return 0===sidebar.widgets.length})).map((function(sidebar){return sidebar.stop_widgets})).reduce((function(all,widgets){return all.concat(widgets)}),[])},Sidebars.new=function(options){var s,arr1,arr2,fixedWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(FixedWidgetClassName).concat(queryElements(compatabilty_FW_v5(options.widgets))))),stopWidgetsSelectors=compatabilty_FW_v5((void 0===(s=options.stop_elements_selectors)&&(s=""),s.replace(/[\r\n]|[\r]/gi,"\n").split("\n").map((function(s){return s.trim()})).filter((function(s){return""!==s})))),stopWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(StopWidgetClassName).concat(queryElements(stopWidgetsSelectors)))),_a=(arr1=fixedWidgetsContainers,[(arr2=stopWidgetsContainers).filter((function(e){return!arr1.includes(e)})),arr1.filter((function(e){return arr2.includes(e)}))]),stopWidgetsUniqContainers=_a[0];_a[1].forEach((function(w){console.error("The Widget is detected as fixed block and stop block!\n".concat(w.innerHTML))})),fixedWidgetsContainers.forEach((function(c){c.classList.add(FixedWidgetClassName)})),stopWidgetsUniqContainers.forEach((function(c){c.classList.add(StopWidgetClassName)}));var sidebars=new Sidebars(fixedWidgetsContainers.concat(stopWidgetsUniqContainers),options);sidebars.mount(),document.addEventListener("scroll",sidebars.render)},Sidebars}();function onDocumentLoaded(){var admin_panel=document.querySelector("#wpadminbar"),options=(window.q2w3_sidebar_options||[{}]).map((function(option){return option.margin_top=(option.margin_top||0)+((null==admin_panel?void 0:admin_panel.clientHeight)||0),option}));options.some((function(option){return window.innerWidth<option.screen_max_width||window.innerHeight<option.screen_max_height}))||function(options){void 0===options&&(options=[]),Sidebars.new(options.reduce((function(prev,cur){return __assign(__assign(__assign({},prev),cur),{widgets:prev.widgets.concat(cur.widgets||[])})}),{widgets:[]}))}(options)}window.addEventListener("load",onDocumentLoaded),"complete"===document.readyState&&onDocumentLoaded();
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
  PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};function __extends(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t},__assign.apply(this,arguments)},StopWidgetClassName="FixedWidget__stop_widget",FixedWidgetClassName="FixedWidget__fixed_widget",Widget=function(){function Widget(el){this.el=el,this.top_offset=0,this.root_offset=0,this.need_to_calc_el_offset=function(_){return!1},this.prevSibling=function(el){return el&&el.previousElementSibling}}return Widget.prototype.render=function(){},Widget.prototype.mount=function(user_margins){void 0===user_margins&&(user_margins={}),this.el&&this.el.parentElement&&(this.top_offset=this.get_total_top_offset(user_margins),this.root_offset=scrollY+this.el.getBoundingClientRect().y)},Widget.prototype.getElement=function(){return this.el},Widget.prototype.toString=function(){var _a;return"".concat(null===(_a=this.el)||void 0===_a?void 0:_a.innerHTML)},Widget.prototype.get_total_top_offset=function(margins){return get_sibilings_offset(this.prevSibling,this.need_to_calc_el_offset,this.prevSibling(this.el),margins.margin_top)},Widget.queryAllWidgetsContainers=function(className){return[].concat(Array.from(document.querySelectorAll(".".concat(className))),Array.from(document.querySelectorAll("[data-fixed_widget=".concat(className)))).map((function(el){el.classList.remove(className),el.removeAttribute("data-fixed_widget");var container=getWidgetContainer(el);return container.classList.remove(FixedWidgetClassName),container.classList.remove(StopWidgetClassName),container}))},Widget.from=function(root,className){var _this=this,elements=[];try{elements=Array.from(root.querySelectorAll(":scope > .".concat(className)))}catch(_e){elements=Array.from(root.children).filter((function(e){return e.classList.contains(className)}))}return elements.filter((function(el){return null!==el})).map((function(e){return new _this(e)}))},Widget}(),getWidgetContainer=function(el){return el.parentElement&&(1===el.parentElement.childElementCount||el.parentElement.classList.toString().includes("wp-block-group")||el.parentElement.classList.toString().includes("wp-block-column")||el.parentElement.classList.contains("widget"))?getWidgetContainer(el.parentElement):el},get_sibilings_offset=function(next,need_to_calc_el_offset,el,offset){if(void 0===offset&&(offset=0),!el)return offset;if(!need_to_calc_el_offset(el))return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset);var _a=getComputedStyle(el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset+el.getBoundingClientRect().height+parseInt(marginTop||"0")+parseInt(marginBottom||"0"))},compatabilty_FW_v5=function(selectors){return void 0===selectors&&(selectors=[]),selectors.some((function(s){return!/^[a-z]/i.test(s)}))?selectors:selectors.concat(selectors.map((function(s){return"#".concat(s)})))},queryElements=function(selectors){return void 0===selectors&&(selectors=[]),Array.from(selectors.map((function(selector){return Array.from(document.querySelectorAll(selector))}))).reduce((function(all,elements){return all.concat(elements)}),[]).filter((function(e){return e instanceof HTMLElement}))};function findWithProperty(el,predicate){return el&&el!==document.body?predicate(getComputedStyle(el))?el:findWithProperty(el.parentElement,predicate):null}var sidebars,reactive=function(getter,interval){void 0===interval&&(interval=300);var subs=[],v=getter();return setInterval((function(){if(0!==subs.length){var new_v=getter();if(v!==new_v){v=new_v;for(var _i=0,subs_1=subs;_i<subs_1.length;_i++){(0,subs_1[_i])(new_v)}}}}),interval),{get val(){return v},on_change:function(update){subs.push(update)}}},PositionWidget=function(_super){function PositionWidget(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.bottom_offset=0,_this.top_margin=0,_this.borderBox=0,_this.block_height=reactive((function(){return 0})),_this.max_top_offset=0,_this.bottom_margin=0,_this.user_margins={},_this.prevSibling=function(el){return el&&!el.classList.contains(StopWidgetClassName)&&el.previousElementSibling||null},_this}return __extends(PositionWidget,_super),PositionWidget.prototype.mount=function(user_margins){var _this=this;if(_super.prototype.mount.call(this,user_margins),this.el&&this.el.parentElement){this.user_margins=user_margins;var _a=getComputedStyle(this.el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;this.bottom_margin=parseInt(marginBottom),this.top_margin=parseInt(marginTop),this.bottom_offset=this.get_total_bottom_offset(user_margins),this.block_height=reactive((function(){return _this.el?Math.round(Math.max(_this.el.clientHeight,_this.el.scrollHeight,_this.el.getBoundingClientRect().height)):0})),this.block_height.on_change((function(block_height){_this.borderBox=block_height+_this.top_margin+_this.bottom_margin}))}},PositionWidget.prototype.setMaxOffset=function(max_top_offset){this.max_top_offset=max_top_offset},PositionWidget.prototype.render=function(){this.onScroll(scrollY)},PositionWidget.from=function(root){return _super.from.call(this,root,FixedWidgetClassName)},PositionWidget.prototype.onScroll=function(_scrollTop){},PositionWidget.prototype.get_total_bottom_offset=function(margins){var next=function(el){return el&&!el.classList.contains(StopWidgetClassName)?el.nextElementSibling:null};return get_sibilings_offset(next,this.need_to_calc_el_offset,next(this.el),margins.margin_bottom)},PositionWidget}(Widget),FixedWidget=function(_super){function FixedWidget(el){var _this=_super.call(this,el)||this;return _this.is_pinned=!1,_this.relative_top=0,_this.paddings=0,_this.init_style={position:"static",marginTop:"",marginBottom:"",width:"",height:""},_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(FixedWidget,_super),FixedWidget.prototype.mount=function(margins){var _this=this;_super.prototype.mount.call(this,margins),this.el&&(this.paddings=this.top_offset+this.top_margin+this.bottom_margin+this.bottom_offset,this.store_style(getComputedStyle(this.el)),this.clone(),this.block_height.on_change((function(block_height){_this.relative_top=_this.max_top_offset-block_height-_this.paddings,_this.init_style.height="".concat(block_height,"px")})))},FixedWidget.prototype.setMaxOffset=function(max_top_offset){max_top_offset<this.root_offset||this.max_top_offset===max_top_offset||(this.max_top_offset=max_top_offset,this.relative_top=this.max_top_offset-this.block_height.val-this.paddings)},FixedWidget.prototype.clone=function(){var _this=this;if(this.el&&this.el.parentElement){for(var prop in this.clone_el=this.el.cloneNode(!1),this.clone_el.getAttributeNames().forEach((function(attr){_this.clone_el.removeAttribute(attr)})),this.init_style)this.clone_el.style[prop]=this.init_style[prop];this.clone_el.style.display="none",this.el.parentElement.insertBefore(this.clone_el,this.el)}},FixedWidget.prototype.store_style=function(style){this.init_style.position=style.position,this.init_style.marginTop=style.marginTop,this.init_style.marginBottom=style.marginBottom,this.init_style.width=style.width,this.init_style.height=style.height},FixedWidget.prototype.restore_style=function(style){this.is_pinned&&(this.is_pinned=!1,style.position=this.init_style.position,this.clone_el&&(this.clone_el.style.display="none"))},FixedWidget.prototype.onScroll=function(scrollTop){if(this.el){var need_to_fix=scrollTop>this.root_offset-this.top_offset,top=0!==this.max_top_offset&&scrollTop>this.relative_top?this.relative_top-scrollTop+this.top_offset:this.top_offset;need_to_fix?this.fix(top):this.restore_style(this.el.style)}},FixedWidget.prototype.fix=function(top){this.el&&(this.el.style.top="".concat(top,"px"),this.is_pinned||(this.is_pinned=!0,this.el.style.position="fixed",this.el.style.transition="transform 0.5s",this.el.style.width=this.init_style.width,this.el.style.height=this.init_style.height,this.clone_el&&(this.clone_el.style.display="block")))},FixedWidget.new=function(selector){return new FixedWidget(document.querySelector(selector))},FixedWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},FixedWidget}(PositionWidget),StickyWidget=function(_super){function StickyWidget(el){var _this=_super.call(this,el)||this;return _this.margins=0,_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(StickyWidget,_super),StickyWidget.prototype.mount=function(margins){_super.prototype.mount.call(this,margins),this.el&&this.el.parentElement&&(this.margins=this.el.parentElement.clientHeight-this.borderBox,this.el.style.position="sticky",this.el.style.position="-webkit-sticky",this.el.style.transition="transform 0s",this.el.style.boxSizing="border-box",this.el.style.top="".concat(this.top_offset,"px"))},StickyWidget.prototype.setMaxOffset=function(max_top_offset){this.el&&this.el.parentElement&&(max_top_offset<this.el.offsetTop||(this.max_top_offset=max_top_offset))},StickyWidget.prototype.onScroll=function(){if(this.el&&this.el.parentElement){var bottom_margin=this.max_top_offset?Math.min(this.max_top_offset-this.el.offsetTop-this.borderBox,this.margins-this.el.offsetTop):this.margins-this.el.offsetTop;bottom_margin>=this.bottom_offset?this.el.style.transform="translateY(0px)":this.el.style.transform="translateY(".concat(bottom_margin-this.bottom_offset,"px)")}},StickyWidget.new=function(selector){return new StickyWidget(document.querySelector(selector))},StickyWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},StickyWidget}(PositionWidget),StopWidget=function(_super){function StopWidget(el){var _this=_super.call(this,el)||this;return _this.need_to_calc_el_offset=function(){return!0},_this.el&&_this.el.parentElement?(_this.el.classList.add(StopWidgetClassName),_this):_this}return __extends(StopWidget,_super),StopWidget.prototype.mount=function(user_margins){var _this=this;_super.prototype.mount.call(this,user_margins),reactive((function(){return Math.round(scrollY+(_this.el?_this.el.getBoundingClientRect().top:0))})).on_change((function(root_offset){_this.root_offset=root_offset}))},StopWidget.new=function(selector){return new StopWidget(document.querySelector(selector))},StopWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(StopWidgetClassName)},StopWidget.from=function(root){return _super.from.call(this,root,StopWidgetClassName)},StopWidget}(Widget),Sidebar=function(){function Sidebar(el,margins,use_sticky_position){var _this=this;void 0===use_sticky_position&&(use_sticky_position=!0),this.el=el,this.margins=margins,this.widgets=[],this.stop_widgets=[],this.isSticky=!0,this.setWidgetsMaxOffset=function(max_offset){for(var _i=0,_a=_this.widgets;_i<_a.length;_i++){_a[_i].setMaxOffset(max_offset)}};var isDeprecatedFloatMarkup=!!findWithProperty(this.el,(function(style){return"none"!==style.float}));isDeprecatedFloatMarkup&&console.log("Fixed Widget: fallback to position sticky"),this.isSticky=!isDeprecatedFloatMarkup&&use_sticky_position;var WidgetContructor=this.isSticky?StickyWidget:FixedWidget;this.stop_widgets=StopWidget.from(this.el),this.widgets=WidgetContructor.from(this.el),this.isSticky&&(this.el.style.position="relative",0===this.stop_widgets.length&&(this.el.style.minHeight="100%"))}return Sidebar.prototype.mount=function(){var _this=this;this.stop_widgets.forEach((function(widget){widget.mount()})),this.widgets.forEach((function(widget){widget.mount(_this.margins)}))},Sidebar.prototype.setMaxOffset=function(common_stop_widgets){var _this=this,stop_widgets=0!=this.stop_widgets.length?this.stop_widgets:common_stop_widgets;if(0!==stop_widgets.length){var max_top_offset=reactive((function(){for(var min_offset=_this.isSticky?stop_widgets[0].top_offset:stop_widgets[0].root_offset,_i=0,stop_widgets_1=stop_widgets;_i<stop_widgets_1.length;_i++){var widget=stop_widgets_1[_i],offset=_this.isSticky?widget.top_offset:widget.root_offset;min_offset>offset&&(min_offset=offset)}return Math.round(min_offset)}));max_top_offset.on_change(this.setWidgetsMaxOffset),this.setWidgetsMaxOffset(max_top_offset.val)}},Sidebar.prototype.render=function(){for(var _i=0,_a=this.stop_widgets;_i<_a.length;_i++){_a[_i].render()}for(var _b=0,_c=this.widgets;_b<_c.length;_b++){_c[_b].render()}},Sidebar}(),Sidebars=function(){function Sidebars(elements,options){var _this=this;this.data=[],this.render=function(){for(var _i=0,_a=_this.data;_i<_a.length;_i++){_a[_i].render()}};var use_sticky_position=void 0===options.use_sticky_position||options.use_sticky_position;this.data=Array.from(new Set(elements.map((function(widget){return widget.parentElement})))).filter((function(sidebar_el){return null!==sidebar_el})).map((function(sidebar_el){return new Sidebar(sidebar_el,options,use_sticky_position)}))}return Sidebars.prototype.mount=function(){this.data.forEach((function(sidebar){sidebar.mount()})),this.setMaxOffset()},Sidebars.prototype.setMaxOffset=function(){for(var general_stop_widgets=this.getGeneralStopElements(),_i=0,_a=this.data;_i<_a.length;_i++){_a[_i].setMaxOffset(general_stop_widgets)}},Sidebars.prototype.getGeneralStopElements=function(){return this.data.filter((function(sidebar){return!sidebar.isSticky||0===sidebar.widgets.length})).map((function(sidebar){return sidebar.stop_widgets})).reduce((function(all,widgets){return all.concat(widgets)}),[])},Sidebars.new=function(options){var s,arr1,arr2,fixedWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(FixedWidgetClassName).concat(queryElements(compatabilty_FW_v5(options.widgets))))),stopWidgetsSelectors=compatabilty_FW_v5((void 0===(s=options.stop_elements_selectors||options.stop_id)&&(s=""),s.replace(/[\r\n]|[\r]/gi,"\n").split("\n").map((function(s){return s.trim()})).filter((function(s){return""!==s})))),stopWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(StopWidgetClassName).concat(queryElements(stopWidgetsSelectors)))),_a=(arr1=fixedWidgetsContainers,[(arr2=stopWidgetsContainers).filter((function(e){return!arr1.includes(e)})),arr1.filter((function(e){return arr2.includes(e)}))]),stopWidgetsUniqContainers=_a[0];return _a[1].forEach((function(w){console.error("The Widget is detected as fixed block and stop block!\n".concat(w.innerHTML))})),fixedWidgetsContainers.forEach((function(c){c.classList.add(FixedWidgetClassName)})),stopWidgetsUniqContainers.forEach((function(c){c.classList.add(StopWidgetClassName)})),new Sidebars(fixedWidgetsContainers.concat(stopWidgetsUniqContainers),options)},Sidebars}();function onDocumentLoaded(){var admin_panel=document.querySelector("#wpadminbar"),options=(window.q2w3_sidebar_options||[{}]).map((function(option){return option.margin_top=(option.margin_top||0)+(admin_panel&&admin_panel.clientHeight||0),option}));options.some((function(option){return window.innerWidth<option.screen_max_width||window.innerHeight<option.screen_max_height}))||function(options){void 0===options&&(options=[]),sidebars?sidebars.render():(sidebars=Sidebars.new(options.reduce((function(prev,cur){return __assign(__assign(__assign({},prev),cur),{widgets:prev.widgets.concat(cur.widgets||[])})}),{widgets:[]})),document.addEventListener("scroll",sidebars.render),sidebars.mount())}(options)}window.addEventListener("load",onDocumentLoaded),"complete"===document.readyState&&onDocumentLoaded(),onDocumentLoaded();
q2w3-fixed-widget.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://wpadvancedads.com/fixed-widget-wordpress/
5
  Description: Use the fixed widget plugin to create sticky widgets that stay in the visible screen area when the page is scrolled up or down and boost your conversions.
6
  Text Domain: q2w3-fixed-widget
7
  Author: Thomas Maier, Max Bond
8
- Version: 6.0.2
9
  Author URI: https://wpadvancedads.com/fixed-widget-wordpress/
10
  */
11
 
@@ -23,7 +23,7 @@ class q2w3_fixed_widget {
23
 
24
  const ID = 'q2w3_fixed_widget';
25
 
26
- const VERSION = '6.0.2';
27
 
28
  protected static $sidebars_widgets;
29
 
5
  Description: Use the fixed widget plugin to create sticky widgets that stay in the visible screen area when the page is scrolled up or down and boost your conversions.
6
  Text Domain: q2w3-fixed-widget
7
  Author: Thomas Maier, Max Bond
8
+ Version: 6.0.3
9
  Author URI: https://wpadvancedads.com/fixed-widget-wordpress/
10
  */
11
 
23
 
24
  const ID = 'q2w3_fixed_widget';
25
 
26
+ const VERSION = '6.0.3';
27
 
28
  protected static $sidebars_widgets;
29
 
readme.txt CHANGED
@@ -1,15 +1,15 @@
1
  === Fixed Widget and Sticky Elements for WordPress ===
2
  Contributors: webzunft, max-bond, advancedads
3
- Tags: fixed widget, sticky widget, sidebar, ads, widget
4
  Requires at least: 5.0
5
  Tested up to: 5.9
6
- Stable tag: 6.0.2
7
 
8
  More attention and a higher ad performance with fixed sticky widgets.
9
 
10
  == Description ==
11
 
12
- Use Fixed Widget to create sticky widgets and other elements that stay in the visible screen area when a user scrolls the page up or down.
13
 
14
  Sticky widgets are more visible than unfixed widgets and therefore have a significantly higher click-through rate.
15
 
@@ -38,7 +38,7 @@ All the features are free.
38
 
39
  * **Sticky Widgets** Use the Fixed Widget option on any widget and blocks in the sidebar
40
  * **Sticky Elements** Choose any element on your site and make it sticky
41
- * **Margin Top** allows you to stop sticky elements to cover sticky menu bars
42
  * **Margin Bottom** pushes sticky elements up before they reach a certain distance towards the bottom window
43
  * **Stop Elements** push sticky elements up when they are scrolling into view
44
  * **Stop Blocks** defines blocks in your sidebar that push fixed blocks out of the page
@@ -76,7 +76,7 @@ Yes, it is possible to fix more than one widget even if they are located in diff
76
  = How to prevent overlapping with the footer? =
77
 
78
  Go to WP admin area, Appearance -> Fixed Widget Options. Here you can define the top and bottom margins. Set bottom margin value >= footer height. Check the result, please.
79
- If your footer height is changing from page to page it is better to use the `Stop ID` option. Here you need to provide the HTML tag ID. The position of that HTML element will determine the margin bottom value. For example, let's take the Twenty Sixteen default theme. The theme's footer container has an id="colophon". In the `Stop Element Selectors` option I need to enter `#colophon`.
80
 
81
  = How to disable the plugin on mobile devices? =
82
 
@@ -91,6 +91,11 @@ Use the options `Minimum Screen Width` and `Minimum Screen Height` to disable st
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
94
  = 6.0.2 =
95
 
96
  - Improvement: Fall back to previous version when the theme does not support the new script – mainly because of using float instead of flex
1
  === Fixed Widget and Sticky Elements for WordPress ===
2
  Contributors: webzunft, max-bond, advancedads
3
+ Tags: fixed widget, sticky widget, sidebar, ads, widget, fixed, sticky, floating, sticky block, adsense
4
  Requires at least: 5.0
5
  Tested up to: 5.9
6
+ Stable tag: 6.0.3
7
 
8
  More attention and a higher ad performance with fixed sticky widgets.
9
 
10
  == Description ==
11
 
12
+ Use Fixed Widget to create sticky widgets, sticky blocks, and other elements that stay in the visible screen area when a user scrolls the page up or down.
13
 
14
  Sticky widgets are more visible than unfixed widgets and therefore have a significantly higher click-through rate.
15
 
38
 
39
  * **Sticky Widgets** Use the Fixed Widget option on any widget and blocks in the sidebar
40
  * **Sticky Elements** Choose any element on your site and make it sticky
41
+ * **Margin Top** allows you to stop sticky elements to cover floating menu bars
42
  * **Margin Bottom** pushes sticky elements up before they reach a certain distance towards the bottom window
43
  * **Stop Elements** push sticky elements up when they are scrolling into view
44
  * **Stop Blocks** defines blocks in your sidebar that push fixed blocks out of the page
76
  = How to prevent overlapping with the footer? =
77
 
78
  Go to WP admin area, Appearance -> Fixed Widget Options. Here you can define the top and bottom margins. Set bottom margin value >= footer height. Check the result, please.
79
+ If your footer height is changing from page to page it is better to use the `Stop ID` option. Here you need to provide the HTML tag ID. The position of that HTML element will determine the margin bottom value. For example, let's take the Twenty Sixteen default theme. The theme's footer container has an ID="colophon". In the `Stop Element Selectors` option I need to enter `#colophon`.
80
 
81
  = How to disable the plugin on mobile devices? =
82
 
91
 
92
  == Changelog ==
93
 
94
+ = 6.0.3 =
95
+
96
+ - Improvement: Check lazy elements and stop elements for changing their size and recalculate fixed position
97
+ - Improvement: Lower check interval from 1000 to 500 ms
98
+
99
  = 6.0.2 =
100
 
101
  - Improvement: Fall back to previous version when the theme does not support the new script – mainly because of using float instead of flex