2016-08-09 65 views
0

我有一个模式,它采用浏览器的全部宽度和高度。在模式中有一个图像内的一个div和一些其他元素,现在我试图在浏览器中使图像全屏,就像YouTube视频全屏显示一样,我已经添加了一个按钮并在其中实现了全屏API,但它不起作用。无法使全屏模式下的图像元素全屏

$('#myModal').on('shown.bs.modal', function() { 
 
    $('#myInput').focus(); 
 
}); 
 

 
$('#dicomModal').on('shown.bs.modal', function() { 
 
    $('#myInput').focus(); 
 
}); 
 

 
$(document).ready(function() { 
 
    $(".js-example-basic-single").select2(); 
 
}); 
 

 
$(function() { 
 
    $('#datetimepicker8').datetimepicker({ 
 

 
    }); 
 
}); 
 

 
$(function() { 
 
    $('#datetimepicker1').datetimepicker({ 
 

 
    }); 
 
}); 
 

 

 
var myImage = document.getElementById('myImage'); 
 
var dicomFull = document.getElementById('dicomFull'); 
 

 
if (dicomFull) { 
 
    dicomFull.addEventListener('click', function() { 
 
    if (myImage.requestFullscreen) { 
 
     myImage.requestFullscreen(); 
 
    } else if (myImage.webkitRequestFullscreen) { 
 
     myImage.webkitRequestFullscreen(); 
 
    } else if (myImage.mozRequestFullScreen) { 
 
     myImage.mozRequestFullScreen(); 
 
    } else if (myImage.msRequestFullscreen) { 
 
     myImage.msRequestFullscreen(); 
 
    } 
 

 
    }); 
 
}
.dicomv { 
 
    &__mods { 
 
    overflow: hidden !important; 
 
    } 
 
    &__items { 
 
    display: inline-block; 
 
    margin-right: 1rem; 
 
    } 
 
    &__navbar { 
 
    width: 100%; 
 
    border-radius: 0; 
 
    min-height: 60px; 
 
    margin: 0; 
 
    top: 0; 
 
    position: fixed; 
 
    z-index: 80; 
 
    } 
 
    &__next { 
 
    padding: 1rem; 
 
    margin-top: 1rem; 
 
    color: map-deep-get($colors, "background", "base"); 
 
    background-color: map-deep-get($colors, "background", "bg-col"); 
 
    &: hover { 
 
     color: map-deep-get($colors, "background", "base"); 
 
     background-color: map-deep-get($colors, "background", "bg-col"); 
 
    } 
 
    &:focus { 
 
     color: map-deep-get($colors, "background", "base"); 
 
     background-color: map-deep-get($colors, "background", "bg-col"); 
 
    } 
 
    } 
 
    &__fs { 
 
    padding: 1rem; 
 
    margin-top: 1rem; 
 
    color: map-deep-get($colors, "background", "base"); 
 
    background-color: map-deep-get($colors, "button", "btn-col"); 
 
    &: hover { 
 
     color: map-deep-get($colors, "background", "base"); 
 
     background-color: map-deep-get($colors, "button", "btn-col"); 
 
    } 
 
    &:focus { 
 
     color: map-deep-get($colors, "background", "base"); 
 
     background-color: map-deep-get($colors, "button", "btn-col"); 
 
    } 
 
    } 
 
    &__container { 
 
    position: relative; 
 
    height: 100vh; 
 
    margin: 0; 
 
    float: left; 
 
    } 
 
    &__button { 
 
    position: absolute; 
 
    left: 0; 
 
    top: 50%; 
 
    z-index: 1; 
 
    margin-top: -3.5rem; 
 
    color: map-deep-get($colors, "background", "base"); 
 
    } 
 
    &__wid { 
 
    width: 100% !important; 
 
    margin-bottom: 0 !important; 
 
    @media (min-width: 768px) { 
 
     margin: 0 auto !important; 
 
    } 
 
    } 
 
    &__mod { 
 
    &--d { 
 
     top: 0 !important; 
 
     @media (min-width: 768px) { 
 
     margin: 0 auto !important; 
 
     } 
 
    } 
 
    } 
 
} 
 
#viewArea { 
 
    margin-left: 0px; 
 
    max-width: 100%; 
 
    background: map-deep-get($colors, "font", "para") 
 
} 
 
.viewport { 
 
    width: 100%; 
 
    height: 100%; 
 
    top: 0px; 
 
    left: 0px; 
 
    position: absolute 
 
} 
 
.imageViewer { 
 
    height: 100%; 
 
} 
 
.viewportWrapper { 
 
    width: 100%; 
 
    height: 100%; 
 
    position: relative; 
 
    color: white; 
 
    display: inline-block; 
 
    background-color: black; 
 
} 
 
.viewer { 
 
    width: 100%; 
 
    height: 100%; 
 
} 
 
.dicom-sidebar-container { 
 
    width: 240px; 
 
    height: 100vh; 
 
    border-right: 1px solid #a1a1a1; 
 
    float: left; 
 
    overflow-y: auto; 
 
} 
 
.dicom-main-container-with-sidebar { 
 
    width: calc(100% - 240px); 
 
} 
 
.dicom-main-container-without-sidebar { 
 
    width: 100%; 
 
} 
 
// 
 
.dicom-sidebar { 
 
    /*margin: 0;*/ 
 
} 
 
.panel-heading { 
 
    padding: 2px 8px; 
 
} 
 
.panel-container { 
 
    margin-left: 1rem; 
 
    border: 1px solid #ccc; 
 
} 
 
.dicom-sidebar-panel { 
 
    margin-bottom: 0; 
 
    border: none; 
 
    border-radius: 0; 
 
    overflow-y: auto; 
 
    -webkit-box-shadow: none; 
 
    box-shadow: none; 
 
} 
 
.dicom-sidebar-panel-body { 
 
    padding: 0 10px 100px 10px; 
 
    overflow-y: auto; 
 
} 
 
.dicom-sidebar-row { 
 
    margin-right: 0; 
 
} 
 
.dicom-sidebar-drawer { 
 
    margin-left: -240px; 
 
} 
 
.dicom-sidebar-inner-box { 
 
    width: 110px; 
 
    padding-left: 3px; 
 
    margin: 1rem 0; 
 
    z-index: 100; 
 
    float: left; 
 
} 
 
.dicom-sidebar-inner-box:nth-child(even) { 
 
    padding-left: 6px; 
 
} 
 
:-webkit-full-screen { 
 
    width: 100%; 
 
    height: 100%; 
 
} 
 
:-moz-full-screen { 
 
    width: 100%; 
 
    height: 100%; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div role="dialog" class="modal dicomv__mods" id="dicomModal" style="z-index: 1050; display:"> 
 
    <div class="modal-dialog modal-lg dicomv__wid"> 
 
    <div class="modal-content"></div> 
 
    <div id="" class="dicomv"> 
 
     <div class="navbar navbar-default dicomv__navbar"> 
 
     <div class="dicom-navbar-container"> 
 

 
      <ul class=""> 
 

 
      <li class="dicomv__items"> 
 
       <a href="#"> 
 
       <button type="button" class="btn btn-default dicomv__fs" id="dicomFull" name="button">View FullScreen</button> 
 
       </a> 
 
      </li> 
 
      </ul> 
 
     </div> 
 
     </div> 
 
     <div id="viewArea" class="row"> 
 
     <div id="dicom_loadbar"></div> 
 
     <div class="dicom-sidebar-container panel panel-default dicom-sidebar-panel"> 
 
      <div class="panel-heading"> 
 
      </div> 
 
      <div class="panel-body dicom-sidebar-panel-body"> 
 

 
      </div> 
 
     </div> 
 

 
     <div class="dicomv__container dicom-main-container dicom-main-container-with-sidebar" id="myImage"> 
 

 
      <div id="myImage"> 
 
      <img src="http://images.newseveryday.com/data/thumbs/full/27419/570/0/0/0/macbook-pro.jpg" id="" alt="" /> 
 

 
      </div> 
 

 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div> 
 
</div>

+0

首先要做的是大大简化你的问题。把所有东西放在最基本的部分。这样可以:a)让其他人更容易看到重要部分是什么,b)更容易看出问题是什么(不存在无关紧要的代码)。 – Whothehellisthat

回答

0

您需要在您的图像上的100%,宽度为它扩展当你去全屏填充容器。所以这可能不会是你的最终代码,但作为一个例子:

if(dicomFull){ 
dicomFull.addEventListener('click',function(){ 
    if(myImage.requestFullscreen){ 
    myImage.requestFullscreen(); 
    }else if (myImage.webkitRequestFullscreen) { 
    myImage.webkitRequestFullscreen(); 
    }else if (myImage.mozRequestFullScreen) { 
    myImage.mozRequestFullScreen(); 
    }else if (myImage.msRequestFullscreen) { 
    myImage.msRequestFullscreen(); 
    } 
    $("#myImage img").css("width", "100%"); 

}); 
} 
+0

无法正常工作,我想将图像制作成完整的视口屏幕,就像它发生在youtube视频中一样。我听说在这个项目中使用JS或jQuery是不可能的,因为我在这个项目的视图层中使用Angular,所以它应该使用Angular来完成,它真的是解决方案吗?如果有人能帮助吗? – ashfaqrafi