javascript - Jssor slider 图像在 Safari 中质量下降

标签 javascript jquery safari

新版本的Jssor不会有这个问题。

<小时/>

Demo

      jQuery(document).ready(function ($) {
          var options = {
              $AutoPlay: true,

              $PauseOnHover: true, //[Optional] Whether to pause when mouse over if a slideshow is auto playing, default value is false

              $ArrowKeyNavigation: true, //Allows arrow key to navigate or not
              $SlideWidth: 141, //[Optional] Width of every slide in pixels, the default is width of 'slides' container
              $SlideHeight: 200, //[Optional] Height of every slide in pixels, the default is width of 'slides' container
              $SlideSpacing: 25, //Space between each slide in pixels
              $DisplayPieces: 3, //Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), the default value is 1
              $ParkingPosition: 0, //The offset position to park slide (this options applys only when slideshow disabled).

              $ArrowNavigatorOptions: { //[Optional] Options to specify and enable arrow navigator or not
                  $Class: $JssorArrowNavigator$, //[Requried] Class to create arrow navigator instance
                  $ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
                  $AutoCenter: 2, //[Optional] Auto center arrows in parent container, 0 No, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
                  $Steps: 1 //[Optional] Steps to go for each navigation request, default value is 1
              }
          };

          var jssor_slider1 = new $JssorSlider$("slider1_container", options);

          //responsive code begin
          //you can remove responsive code if you don't want the slider scales while window resizes
          function ScaleSlider() {
              var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
              if (parentWidth) jssor_slider1.$ScaleWidth(Math.min(parentWidth, 800));
              else window.setTimeout(ScaleSlider, 30);
          }

          ScaleSlider();

          if (!navigator.userAgent.match(/(iPhone|iPod|iPad|BlackBerry|IEMobile)/)) {
              $(window).bind('resize', ScaleSlider);
          }
          //if (navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
          //    $(window).bind("orientationchange", ScaleSlider);
          //}
          //responsive code end

      });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://www.jssor.com/js/jssor.slider.js"></script>
<script src="http://www.jssor.com/js/jssor.js"></script>
<div id="slider1_container" style="position: relative; top: 0px; left:0 px; width: 420px;
        height: 245px;">
    <div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 420px; height: 245px;
            overflow: hidden;">
        <div>
            <img u="image" src="http://www.jssor.com/img/landscape/02.jpg" class="tissue_image" />
        </div>
        <div>
            <img u="image" src="http://www.jssor.com/img/landscape/03.jpg" class="tissue_image" />
        </div>
        <div>
            <img u="image" src="http://www.jssor.com/img/landscape/04.jpg" class="tissue_image" />
        </div>
        <div>
            <img u="image" src="http://www.jssor.com/img/landscape/05.jpg" class="tissue_image" />
        </div>
    </div>
</div>

在演示中,图像在 safari 中质量下降,但在其他浏览器中正常。

如何通过程序解决这个问题?

有一些相关问题,要求手动更改原始图像大小以适合容器,但由于某种原因,我无法手动更改大小,必须通过程序来更改大小。

我认为需要修改“jssor.slider.js”或“jssor.slider.js”以了解如何生成 slider 图像,但我不知道这是否是正确的方法。

任何知道“jssor slider”的人都会帮助我吗?谢谢!!!

最佳答案

我在 Safari 和 JSSOR 上也遇到过这个问题。 Safari 对指定图像尺寸与实际图像尺寸非常挑剔,而其他主要浏览器似乎忽略它而支持响应式代码。标准演示(以及代码示例中,除非您更改它们)中使用的图像是 600x300px,但您为 slider 容器和幻灯片本身指定 420x245。将这两个值更改为您正在使用的图像的实际大小,Safari 将正常工作。

关于javascript - Jssor slider 图像在 Safari 中质量下降,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26401447/

相关文章:

javascript - 当 https 成功时在 Controller 之间传递数据

javascript - 仅当再次单击时才关闭页面操作弹出窗口

javascript - 如果我绑定(bind)一个已经绑定(bind)的 JQuery 事件会发生什么?

html - nth-of-type(x)(带有媒体查询)在 Safari 9.1.1 中无法正常工作

html - 背景尺寸; Safari 9 上的奇怪行为

javascript - 循环嵌套 JavaScript 数组时出现问题

javascript - 如何在 jQuery 'each' 函数及其包含的所有 AJAX 调用之后触发我的函数?

jquery - 展开/折叠网页上的内容 [还可以在单​​击时加载内容]

javascript - 如何在不重新加载 JSON 更新页面的情况下更新 div 的类和内容

objective-c - 如何通过 mac os x api 获取 Safari.app 的包标识符