javascript - 响应式文件管理器将图像打开为图库

标签 javascript jquery html css responsive-filemanager

我正在使用 Responsive File Manager对于我的元素中的网络文件管理器。
它工作正常。

问题

我的问题是当我打开图像时,它在 lightbox modal 中显示预览.
我怎样才能把它变成像 navigating between Image 这样的图片库?

<a class="tip-right preview" title="<?php echo trans('Preview')?>" data-url="<?php echo $src;?>" data-toggle="lightbox" href="#previewLightbox">
  <i class=" icon-eye-open"></i>
</a>

JS

这里有一段代码 JS 代码在 include.js文件
r.on("click", ".preview", function() {
  var e = jQuery(this);
  return 0 == e.hasClass("disabled") && jQuery("#full-img").attr("src", decodeURIComponent(e.attr("data-url")))

HTML
<div id="previewLightbox" class="lightbox hide fade"  tabindex="-1" role="dialog" aria-hidden="true">
    <div class='lightbox-content'>
        <img id="full-img" src="">
    </div>
</div>

Fiddle Here

最佳答案

根据我的经验,在编辑他们的经理方面你无能为力。
但是,使用一些 CSS 和 Javascript 制作自己的内容非常容易。
Fiddle
Learning Tutorial
HTML:

 <div id="slider" class="slider">
      <div class="wrapper">
        <div id="items" class="items">
          <span class="slide"><img src="image1"/></span>
          <span class="slide"><img src="image2"/></span>
          <span class="slide"><img src="image3"/></span>
        </div>
      </div>
      <a id="prev" class="control prev"></a>
      <a id="next" class="control next"></a>
    </div>
CSS:
.slider {
  width: 300px;
  height: 200px;
}
.wrapper {
  overflow: hidden;
  position: relative;
  background: #222;
  z-index: 1;
}
#items {
  width: 10000px;
  position: relative;
  top: 0;
  left: -300px;
}
#items.shifting {
  transition: left .2s ease-out;
}
.slide {
  width: 300px;
  height: 200px;
  cursor: pointer;
  float: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 1s;
  position: relative;
}

.control {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 40px;
  background: #fff;
  border-radius: 20px;
  margin-top: -20px;
  box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.3);
  z-index: 2;
}
.prev,
.next {
  background-size: 22px;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}
.prev {
  background-image: url(ChevronLeft.png);
  left: -20px;
}
.next {
  background-image: url(ChevronRight-512.png);
  right: -20px;
}
.prev:active,
.next:active {
  transform: scale(0.8);
}
Javascript:
var slider = document.getElementById('slider'),
    sliderItems = document.getElementById('items'),
    prev = document.getElementById('prev'),
    next = document.getElementById('next');
slide(slider, sliderItems, prev, next);
function slide(wrapper, items, prev, next) {
  var posX1 = 0,
      posX2 = 0,
      posInitial,
      posFinal,
      threshold = 100,
      slides = items.getElementsByClassName('slide'),
      slidesLength = slides.length,
      slideSize = items.getElementsByClassName('slide')[0].offsetWidth,
      firstSlide = slides[0],
      lastSlide = slides[slidesLength - 1],
      cloneFirst = firstSlide.cloneNode(true),
      cloneLast = lastSlide.cloneNode(true),
      index = 0,
      allowShift = true;
  
  // Clone first and last slide
  items.appendChild(cloneFirst);
  items.insertBefore(cloneLast, firstSlide);
  wrapper.classList.add('loaded');
  
  // Mouse and Touch events
  items.onmousedown = dragStart;
  
  // Touch events
  items.addEventListener('touchstart', dragStart);
  items.addEventListener('touchend', dragEnd);
  items.addEventListener('touchmove', dragAction);
  
  // Click events
  prev.addEventListener('click', function () { shiftSlide(-1) });
  next.addEventListener('click', function () { shiftSlide(1) });
  
  // Transition events
  items.addEventListener('transitionend', checkIndex);
  
  function dragStart (e) {
    e = e || window.event;
    e.preventDefault();
    posInitial = items.offsetLeft;
    
    if (e.type == 'touchstart') {
      posX1 = e.touches[0].clientX;
    } else {
      posX1 = e.clientX;
      document.onmouseup = dragEnd;
      document.onmousemove = dragAction;
    }
  }
  function dragAction (e) {
    e = e || window.event;
    
    if (e.type == 'touchmove') {
      posX2 = posX1 - e.touches[0].clientX;
      posX1 = e.touches[0].clientX;
    } else {
      posX2 = posX1 - e.clientX;
      posX1 = e.clientX;
    }
    items.style.left = (items.offsetLeft - posX2) + "px";
  }
  
  function dragEnd (e) {
    posFinal = items.offsetLeft;
    if (posFinal - posInitial < -threshold) {
      shiftSlide(1, 'drag');
    } else if (posFinal - posInitial > threshold) {
      shiftSlide(-1, 'drag');
    } else {
      items.style.left = (posInitial) + "px";
    }
    document.onmouseup = null;
    document.onmousemove = null;
  }
  
  function shiftSlide(dir, action) {
    items.classList.add('shifting');
    
    if (allowShift) {
      if (!action) { posInitial = items.offsetLeft; }
      if (dir == 1) {
        items.style.left = (posInitial - slideSize) + "px";
        index++;      
      } else if (dir == -1) {
        items.style.left = (posInitial + slideSize) + "px";
        index--;      
      }
    };
    
    allowShift = false;
  }
    
  function checkIndex (){
    items.classList.remove('shifting');
    if (index == -1) {
      items.style.left = -(slidesLength * slideSize) + "px";
      index = slidesLength - 1;
    }
    if (index == slidesLength) {
      items.style.left = -(1 * slideSize) + "px";
      index = 0;
    }
    
    allowShift = true;
  }
}

关于javascript - 响应式文件管理器将图像打开为图库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44537180/

相关文章:

html - 不能在另一个 div 中定位 div

jQuery 动画字体大小减小 : animate shrinking from all sides

javascript - 为什么我需要点击两次才能运行一个功能?

php - JQuery 变量到 PHP session

javascript - 打印时如何启用所有禁用

jquery UI sortable - 允许拖动嵌入在可排序 div 中的图像以导致 div 排序的开始

html - 带有 'display: inline-block;' 的字符串不会分行

javascript - 如何在extjs中销毁Panel

javascript - Jquery 更改类单击

javascript - 使用对象选择根元素后,如何选择子元素?