doujia1988 2018-11-05 11:08
浏览 124

Magnific popup,选择最后显示的图像

I have a list of thumbnails, when clicking on one of the thumbnails it shows the image in a popup with the Magnific script popup.

When clicking on a thumbnail I also show a border around the thumbnail that was just clicked on. This is simply done with:

function SelectPicture(picture_id) {
$("li").removeClass('add_border_image');
$("li#picture_"+picture_id).addClass('add_border_image');}

However when looking at and navigating through the larger images, I need to select each thumbnail by showing a border around it. So that when the popup is closed, the user can see which image was the last one that he looked at.

I know that I can override the close button like this:

  callbacks: {
    open: function() {
      $.magnificPopup.instance.close = function() {
        $("li").removeClass('add_border_image');
        $("li#picture_156259").addClass('add_border_image');    
        $.magnificPopup.proto.close.call(this);
      };
    }
  },

But how to pass the id of the current showing image to the right thumbnail, so that it shows the border? In above callback everything works like expected, but here the id of the thumbnail is hardcoded for testing.

  • 写回答

1条回答 默认 最新

  • dongtou2016 2018-11-05 16:13
    关注

    Got it working by using the index of the larger image and with that index adding the class to the corresponding thumbnail with the same index.

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)