Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JS图像大小与fullPage.JS兼容_Javascript_Compatibility_Fullpage.js - Fatal编程技术网

Javascript JS图像大小与fullPage.JS兼容

Javascript JS图像大小与fullPage.JS兼容,javascript,compatibility,fullpage.js,Javascript,Compatibility,Fullpage.js,我正在尝试集成这段代码:在使用fullpage.js的网站的某个部分 此代码基于@Seika85出色地回答的前一个问题:。 其目的是“包含”并调整容器“.plancheBox”上的图像大小,而无需对其进行剪切 在本例中,cat图片的尺寸由容器使用以下第一个javascript代码驱动: var calculateImageDimension = function() { $('.plancheBox img').each(function() { var $img = $(thi

我正在尝试集成这段代码:在使用fullpage.js的网站的某个部分

此代码基于@Seika85出色地回答的前一个问题:。 其目的是“包含”并调整容器“.plancheBox”上的图像大小,而无需对其进行剪切

在本例中,cat图片的尺寸由容器使用以下第一个javascript代码驱动:

var calculateImageDimension = function() {

  $('.plancheBox img').each(function() {

    var $img = $(this),
      $plancheBox = $img.closest('.plancheBox');

    $img.css({
      'max-height': $plancheBox.height() + 2,
      /* (+2px) prevent thin margins due to rendering */
      'max-width': $plancheBox.width()
    });

    $img.closest('.container').css({
      'position': 'relative'
    });

  });
}

calculateImageDimension();
var resizeEnd;
$(window).on('resize', function() {
  clearTimeout(resizeEnd);
  resizeEnd = setTimeout(function() {
    $(window).trigger('resize-end');
  }, 200);
});

$(window).on('resize-end', function() {

  $('.plancheBox img').css({
    'max-height': 'none',
    'max-width': 'none'
  })
  $('.plancheBox .container').css({
    'position': ''
  });

  calculateImageDimension();
});
为了即时设置这些维度(无需页面刷新),我使用了第二个javascript代码:

var calculateImageDimension = function() {

  $('.plancheBox img').each(function() {

    var $img = $(this),
      $plancheBox = $img.closest('.plancheBox');

    $img.css({
      'max-height': $plancheBox.height() + 2,
      /* (+2px) prevent thin margins due to rendering */
      'max-width': $plancheBox.width()
    });

    $img.closest('.container').css({
      'position': 'relative'
    });

  });
}

calculateImageDimension();
var resizeEnd;
$(window).on('resize', function() {
  clearTimeout(resizeEnd);
  resizeEnd = setTimeout(function() {
    $(window).trigger('resize-end');
  }, 200);
});

$(window).on('resize-end', function() {

  $('.plancheBox img').css({
    'max-height': 'none',
    'max-width': 'none'
  })
  $('.plancheBox .container').css({
    'position': ''
  });

  calculateImageDimension();
});
正如您在第一个示例中看到的,它在没有fullpage.js的情况下工作

我设法在fullpage.JS网站中插入了第一个JS代码:但我并没有真正插入第二个代码

我实际上不是一个JS编码员,所以我想知道我需要做什么来插入这段代码,是否可以用fullpage.JS来完成,以及这两段代码之间是否有冲突


谢谢你的回答

第二个JS代码必须插入完整页面事件中,如下所示:

$(document).ready(function() {
    $('#fullpage').fullpage({
        //events
        afterResize: function(){
            $('.plancheBox img').css({
            'max-height' : 'none',
            'max-width'  : 'none'
          })
          $('.plancheBox .conteneur').css({'position' : ''});

          calculateImageDimension();
        }
    });
});