選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

42 行
836 B

  1. // const $ = require('jquery');
  2. const $ = require('jquery');
  3. const ihk = require('../ihk');
  4. ihk.Sidebar = function(sidebar) {
  5. const t = this;
  6. t.sidebar = sidebar.addClass('initiated');
  7. t.timer = null;
  8. t.sidebar.on('resize', function () {
  9. t.onResize();
  10. }).trigger('resize');
  11. $(window).on('resize', function () {
  12. t.onResize();
  13. })
  14. }
  15. ihk.Sidebar.prototype.onResize = function() {
  16. const t = this;
  17. if (t.timer) {
  18. clearTimeout(t.timer);
  19. }
  20. t.timer = setTimeout(function () {
  21. if (t.sidebar.outerHeight() < $(window).height() - 180) {
  22. t.sidebar.addClass('sticky');
  23. }
  24. else {
  25. t.sidebar.removeClass('sticky');
  26. }
  27. }, 250)
  28. };
  29. $('body').on('ihk-init dynamic-component-loaded', function () {
  30. $('.sidebar:not(.initiated)').each(function(i) {
  31. new ihk.Sidebar($(this));
  32. });
  33. })