div全屏编辑和退出全屏

封装全屏和退出全屏fullScreen.js
/**
 *div 全屏
*/
var thatObj=null
var domName=null
var fullscreenFun = function (dom,that) {
  // 如果不允许进入全屏,发出不允许提示
  thatObj=that
  domName=dom
  var fullscreen = false;
  let fullarea = document.getElementById(dom);//设置后就是   id==con_lf_top_div 的容器全屏
  let fullScreenHeight=screen.height;

  if (fullscreen) {    // 退出全屏
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.webkitCancelFullScreen) {
      document.webkitCancelFullScreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    }
  } else {    // 进入全屏
    if (fullarea.requestFullscreen) {
      fullarea.requestFullscreen();
    } else if (fullarea.webkitRequestFullScreen) {
      fullarea.webkitRequestFullScreen();
    } else if (fullarea.mozRequestFullScreen) {
      fullarea.mozRequestFullScreen();
    } else if (fullarea.msRequestFullscreen) {
      // IE11
      fullarea.msRequestFullscreen();
    }
    if(dom=='screenBox'){
      if(thatObj.form.scriptLanguage=="javascript"){
        thatObj.aceDefulatHeight=fullScreenHeight+'px'
      }else{
        thatObj.ace1DefulatHeight='200px'
        thatObj.aceDefulatHeight=fullScreenHeight-270+'px'
      }
      
    }
    
  }
  fullscreen = !fullscreen;
  
  // that.isFullScence = !that.isFullScence;
}
export default fullscreenFun;

//监听退出全屏事件
document.addEventListener("fullscreenchange", function (e) {
  if (document.fullscreenElement) {//进入全屏
    if(domName=='screenBox' || domName=='bigBox'||domName=='tableTest' || domName=='resBox'){
      if(thatObj){
        thatObj.isFullscreen=true;
      }
    }
  } else {//退出全屏
    if(domName=='screenBox' || domName=='bigBox'||domName=='tableTest' || domName=='resBox'){
      if(thatObj){
        thatObj.isFullscreen=false;
        thatObj.ace1DefulatHeight='150px'
        thatObj.aceDefulatHeight='300px'
      }
      
    }
  }
})
html
  <div class="ace-style" id="templateBigBox">编辑器元素</div>
//页面引用
import fullscreenFun from '@/xxx/fullScreen';
//方法调用
 //全屏
screen(){
   // 如果不允许进入全屏,发出不允许提示
   fullscreenFun("templateBigBox",this);//templateBigBox编辑器元素id
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值