<i id='eMROI'><tr id='eMROI'><dt id='eMROI'><q id='eMROI'><span id='eMROI'><b id='eMROI'><form id='eMROI'><ins id='eMROI'></ins><ul id='eMROI'></ul><sub id='eMROI'></sub></form><legend id='eMROI'></legend><bdo id='eMROI'><pre id='eMROI'><center id='eMROI'></center></pre></bdo></b><th id='eMROI'></th></span></q></dt></tr></i><div id='eMROI'><tfoot id='eMROI'></tfoot><dl id='eMROI'><fieldset id='eMROI'></fieldset></dl></div>
      <bdo id='eMROI'></bdo><ul id='eMROI'></ul>

    <tfoot id='eMROI'></tfoot>

    <small id='eMROI'></small><noframes id='eMROI'>

        <legend id='eMROI'><style id='eMROI'><dir id='eMROI'><q id='eMROI'></q></dir></style></legend>

        jQuery Masonry 和 Ajax-fetching 追加项目导致图像重叠

        jQuery Masonry and Ajax-fetching to Append Items Causing Image Overlap(jQuery Masonry 和 Ajax-fetching 追加项目导致图像重叠)
      1. <legend id='ge4qk'><style id='ge4qk'><dir id='ge4qk'><q id='ge4qk'></q></dir></style></legend>

        • <small id='ge4qk'></small><noframes id='ge4qk'>

          • <tfoot id='ge4qk'></tfoot>

              <tbody id='ge4qk'></tbody>
              <bdo id='ge4qk'></bdo><ul id='ge4qk'></ul>
                <i id='ge4qk'><tr id='ge4qk'><dt id='ge4qk'><q id='ge4qk'><span id='ge4qk'><b id='ge4qk'><form id='ge4qk'><ins id='ge4qk'></ins><ul id='ge4qk'></ul><sub id='ge4qk'></sub></form><legend id='ge4qk'></legend><bdo id='ge4qk'><pre id='ge4qk'><center id='ge4qk'></center></pre></bdo></b><th id='ge4qk'></th></span></q></dt></tr></i><div id='ge4qk'><tfoot id='ge4qk'></tfoot><dl id='ge4qk'><fieldset id='ge4qk'></fieldset></dl></div>
                  本文介绍了jQuery Masonry 和 Ajax-fetching 追加项目导致图像重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这里使用 Masonry 和 Ajax 在 Wordpress 中附加项目的另一个图像重叠问题.第一次添加更多项目时,图像会重叠.但是,当页面重新加载时,图像不再重叠.经过一些研究,我意识到这与计算图像的高度有关.

                  Another image overlap issue here using Masonry and Ajax to append items in Wordpress. The first time more items are appended, the images overlap. However, when the page is reloaded, the images no longer overlap. I realize after doing some research this has to do with calculating the height of the images.

                  在 Masonry 网站的帮助页面中,建议使用 getimagesize 函数来指定图像的宽度和高度.

                  From the help page on the Masonry website, it is suggested to use the getimagesize function in order to specify the width and height of the images.

                  但是,这就是我卡住的地方.由于我对 PHP 的了解有限,我不知道如何使用这个函数或将它放在我的代码中的什么位置,所以我在这里寻找一点方向.谁能帮我弄清楚如何将 getimagesize 函数集成到我的代码中?

                  However, this is where I am stuck. Because of my limited knowledge of PHP, I have no idea how to utilize this function or where to place it in my code, so I'm looking for a little direction here. Can anyone help me figure out how to integrate the getimagesize function into my code?

                  这是砌体代码:

                  $(document).ready(function(){
                  
                      var $container = $('#loops_wrapper');
                  
                      $container.imagesLoaded( function(){
                        $container.masonry({
                          itemSelector : '.post_box',
                          columnWidth: 302
                  
                          });
                        });
                      });
                  

                  这是 ajax 获取代码:

                  This is the ajax fetching code:

                  $('.load_more_cont a').live('click', function(e) {
                      e.preventDefault();
                      $(this).addClass('loading').text('Loading...');
                      $.ajax({
                          type: "GET",
                          url: $(this).attr('href') + '#loops_wrapper',
                          dataType: "html",
                          success: function(out) {
                              result = $(out).find('.post_box');
                              nextlink = $(out).find('.load_more_cont a').attr('href');
                  
                              $('#loops_wrapper').append(result).masonry('appended', result);
                              $('.load_more_cont a').removeClass('loading').text('Load more posts');
                  
                              if (nextlink != undefined) {
                                  $('.load_more_cont a').attr('href', nextlink);
                              } else {
                                  $('.load_more_cont').remove();
                              }
                          }
                      });
                  });
                  

                  推荐答案

                  您可以尝试在此处实现 David DeSandro 的计时器方法来附加图像...

                  You could try to implement David DeSandro's timer approach here for appending images...

                  正如入门所推荐的,处理图像的最佳解决方案是在 img 标签中定义尺寸属性,尤其是在使用无限滚动时.这是下面示例中采用的解决方案.

                  "As recommended in the primer, the best solution to handle images is to have the size attributes defined in the img tag, especially when using Infinite Scroll. This is the solution employed in the example below.

                  当然,这在某些 CMS 中不是一个可行的选择,尤其是 Tumblr.在这种情况下,需要在新附加的图像完全加载后调用 Masonry.这是通过延迟 Masonry 回调来完成的."

                  Of course, this is not a viable option in some CMSs, most notably Tumblr. In this situation, Masonry needs to be called after the newly-appended images are fully loaded. This is done by delaying the Masonry callback."

                  function( newElements ) {
                      setTimeout(function() {
                      $wall.masonry({ appendedContent: $(newElements) });
                      }, 1000);
                  }
                  

                  编辑:如果您无法实现无限滚动附加项目的常见延迟想法,您可以尝试在附加新项目后重新加载,而不是

                  EDIT: If you can't implement the common delay idea for appending items with infinite scroll, you could try reloading after appending new items so instead of

                  $('#loops_wrapper').append(result).masonry('appended', result);
                  

                  这样做

                  $("#loops_wrapper").append(result).masonry('reload');
                  

                  这篇关于jQuery Masonry 和 Ajax-fetching 追加项目导致图像重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                  Ajax call in rails 3.2.3 with will_paginate gem(使用 will_paginate gem 在 Rails 3.2.3 中调用 Ajax)
                  Attach or embed node add form with a view(使用视图附加或嵌入节点添加表单)
                  Drupal: How to submit the webfrom from REST services using AJAX POST(Drupal:如何使用 AJAX POST 从 REST 服务提交 webfrom)
                  Drupal 7 Field API: how to programmatically send AJAX request specified in #ajax property of form element?(Drupal 7 Field API:如何以编程方式发送表单元素的#ajax属性中指定的AJAX请求?)
                  <tfoot id='E1Cto'></tfoot><legend id='E1Cto'><style id='E1Cto'><dir id='E1Cto'><q id='E1Cto'></q></dir></style></legend>

                1. <i id='E1Cto'><tr id='E1Cto'><dt id='E1Cto'><q id='E1Cto'><span id='E1Cto'><b id='E1Cto'><form id='E1Cto'><ins id='E1Cto'></ins><ul id='E1Cto'></ul><sub id='E1Cto'></sub></form><legend id='E1Cto'></legend><bdo id='E1Cto'><pre id='E1Cto'><center id='E1Cto'></center></pre></bdo></b><th id='E1Cto'></th></span></q></dt></tr></i><div id='E1Cto'><tfoot id='E1Cto'></tfoot><dl id='E1Cto'><fieldset id='E1Cto'></fieldset></dl></div>
                    <bdo id='E1Cto'></bdo><ul id='E1Cto'></ul>
                        <tbody id='E1Cto'></tbody>
                    • <small id='E1Cto'></small><noframes id='E1Cto'>