Search code examples
jqueryhtmlcsscarouselpopupwindow

Responsive iframe carousel modal?


I want to add to my Tumblr a popup/modal div-based carousel (for lack of a better term--I don't want a simple image carousel) that is navigable via a bottom-aligned menu, either directly in the modal or as an iframe. Having not been able to find resources to build it the former way, I opted for the latter. While viewport units seem to make the to-be-iframed page generally correctly width-responsive (there is an increasing right offset that larger vw's won't fix), height-responsiveness breaks when I either resize the source page or stuff it into the final modal, preventing me from accessing the navigation menu. How can I make the iframe carousel properly size-responsive; or can someone point me to the proper way to build a popup div carousel? Here is a JSFiddle for my dilemma, as well as the iframed page (code accessible via pastebin).

HTML:

<div id="main">
    <ul id="nav">
        <li class="changer changer1 active" data-slidey="1"><span>ITEM 1</span></li><!--
        --><li class="changer changer2" data-slidey="2"><span>ITEM 2</span></li><!--
        --><li class="changer changer3" data-slidey="3"><span>ITEM 3</span></li><!--
  --><li class="changer changer4" data-slidey="4"><span>ITEM 4</span></li>
  <li class="changer changer5" data-slidey="5"><span>ITEM 5</span></li>
</ul>

    <div id="carousel" class="slidey1"><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
        </div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
        </div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
        </div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
</div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
</div>
</div>
</div>

CSS:

        #main {
            background:#fff;
            border:1px solid #eaeaea;
            height:100vw;
            width:100vw;
            text-align:center;
            padding:25px;
            font-family:'open sans', sans-serif;
            font-size:11px;
            overflow:hidden;
        }
        ul#nav {
            padding:0;
            margin:0;
            list-style:none;
            width:100vw;
            position:absolute;
            bottom:0vw;
            padding-top:15px;
            border-top:1px solid #eaeaea;
            color:#222;
            display:flex;
        }
        ul#nav li {
            display:inline-block;
            width:100px;
            overflow:hidden;
            line-height:20px;
            font-size:11px;
            text-transform:uppercase;
            letter-spacing:1.1px;
            cursor:pointer;
            position:relative;
            font-weight:bold;
            flex:1;
        }

[...]

        #carousel {
            width:500vw;
            position:absolute;
            top:10px;
            text-align:left;
        }
        .slidey1 {
            margin-left: 0vw;
            -webkit-transition: all 0.3s linear;
            -moz-transition: all 0.3s linear;
            -o-transition: all 0.3s linear;
            transition: all 0.3s linear;
        }

        /* my actual code contains 5 different slidey# classes, with the slidey number increasing by 1 (up 
           to .slidey4) and the margin-left decreasing by 100vw (down to -400vw) */

        .box {
            height:92vh;
            padding:0 15px;
            display:inline-block;
            width:94.5vw;
            vertical-align:top;
            margin-right:25px;
            text-align:center;
        }

JS:

       (function($){ $(document).ready(function(){ $("[title],a[title],img[title]").style_my_tooltips({ tip_follows_cursor:true, tip_delay_time:100, tip_fade_speed:300, attribute:"title" }); }); })(jQuery);
       $(document).ready(function() {
          $(".changer").click(function(){
            $("#carousel").removeClass();
            $("#carousel").addClass("slidey" + $(this).data("slidey"));
            $(".changer1, .changer2, .changer3, .changer4, .changer5").removeClass("active");
            $(".changer" + $(this).data("slidey")).addClass("active");
            return false;
        });
          $('ul.tags li a').on({
           mouseenter: function() {
               $(this).parent().addClass('hovered');
           },
           mouseleave: function() {
               $(this).parent().removeClass('hovered');
           }
       });
      })

Thank you!


Solution

  • I figured out a way to make a CSS-only (vertical, but it shouldn't be difficult to make it horizontal) carousel that, if pulled off right, should be able to make modal/iframe usage completely unnecessary. If anyone else should be interested, this is the tutorial I found: https://yeolithm.com/carousel/tutorial