GithubHelp home page GithubHelp logo

mirari / vue-fullscreen Goto Github PK

View Code? Open in Web Editor NEW
430.0 7.0 49.0 4.38 MB

A simple Vue.js component for fullscreen

License: MIT License

JavaScript 34.83% Vue 48.84% HTML 12.82% Shell 0.57% TypeScript 2.93%

vue-fullscreen's Introduction

vue-fullscreen

A simple Vue.js component for fullscreen, based on screenfull.js

npm version language

npm version language

npm download license

Quick Example

Support

Supported browsers

Note: In order to use this package in Internet Explorer, you need a Promise polyfill.

Note: Safari is supported on desktop and iPad, but not on iPhone.

Note: Navigating to another page, changing tabs, or switching to another application using any application switcher (or Alt-Tab) will likewise exit full-screen mode.

Learn more

Migration from <= 2.3.5

Component

In general, you can simply switch the fullscreen state using two-way binding, so you don't have to call the component methods directly.

The background prop are removed, you can set it directly on the component

Api

The wrapper and options such as background associated with it are removed, which has limited use cases, is not very customizable, and you can simply implement it yourself.

The method names are changed as follows:

old new
enter request
support isEnabled
getState() isFullscreen

Installation

Install from NPM

npm install vue-fullscreen@legacy

Usage

To use vue-fullscreen, simply import it, and call Vue.use() to install.

The component, directive and api will be installed together in the global.

<template>
  <div>
    <!-- Component  -->
    <fullscreen v-model="fullscreen">
      content
    </fullscreen>
    <button type="button" @click="toggle" >Fullscreen</button>
    <!-- Api  -->
    <button type="button" @click="toggleApi" >FullscreenApi</button>
    <!-- Directive  -->
    <button type="button" v-fullscreen >FullscreenDirective</button>
  </div>
</template>
<script>
  import VueFullscreen from 'vue-fullscreen'
  import Vue from 'vue'
  Vue.use(VueFullscreen)
  export default {
    methods: {
      toggle () {
        this.fullscreen = !this.fullscreen
      },
      toggleApi () {
        this.$fullscreen.toggle()
      },
    },
    data() {
      return {
        fullscreen: false,
      }
    }
  }
</script>

Caution: Because of the browser security function, you can only call these methods by a user gesture(click or keypress).

Usage of api

In your vue component, You can use this.$fullscreen to get the instance.

this.$fullscreen.toggle()

Or you can just import the api method and call it.

<template>
  <div>
    <div class="fullscreen-wrapper">
      Content
    </div>
    <button type="button" @click="toggle" >Fullscreen</button>
  </div>
</template>
<script>
import { api as fullscreen } from 'vue-fullscreen'
export default {
  methods: {
    async toggle () {
      await fullscreen.toggle(this.$el.querySelector('.fullscreen-wrapper'), {
        teleport: this.teleport,
        callback: (isFullscreen) => {
          //this.fullscreen = isFullscreen
        },
      })
      this.fullscreen = fullscreen.isFullscreen
    },
  },
  data() {
    return {
      fullscreen: false,
      teleport: true,
    }
  }
}
</script>

Methods & Attributes

toggle([target, options, force])

Toggle the fullscreen mode.

  • target:
    • Type: Element
    • Default: document.body
    • The element target for fullscreen.
  • options (optional):
    • Type: Object
    • The fullscreen options.
  • force (optional):
    • Type: Boolean
    • Default: undefined
    • pass true to force enter , false to exit fullscreen mode.

request([target, options])

enter the fullscreen mode.

  • target:
    • Type: Element
    • Default: document.body
    • The element target for fullscreen.
  • options (optional):
    • Type: Object
    • The fullscreen options.

exit()

exit the fullscreen mode.

Note: Each of these methods returns a promise object, and you can get the state after the promise has been resolved, or you can pass a callback function in options to get.

async toggle () {
  await this.$fullscreen.toggle()
  this.fullscreen = this.$fullscreen.isFullscreen
}

isFullscreen

get the fullscreen state.

  • Type: Boolean

Caution: The action is asynchronous, you can not get the expected state immediately following the calling method.

isEnabled

check browser support for the fullscreen API.

  • Type: Boolean

element

get the fullscreen element.

  • Type: Element | null

Options

callback

  • Type: Function
  • Default: null

It will be called when the fullscreen mode changed.

fullscreenClass

  • Type: String
  • Default: fullscreen

The class will be added to target element when fullscreen mode is on.

pageOnly

  • Type: Boolean
  • Default: false

If true, only fill the page with current element.

Note: If the browser does not support full-screen Api, this option will be automatically enabled.

teleport

  • Type: Boolean
  • Default: true

If true, the target element will be appended to document.body when it is fullscreen.

This can avoid some pop-ups not being displayed.

Use as directive

You can use v-fullscreen to make any element have the effect of switching to full screen with a click.

<button v-fullscreen>FullScreen</button>

Or you can just import the directive and install it.

<template>
  <div>
    <div class="fullscreen-wrapper">
      Content
    </div>
    <button type="button" v-fullscreen.teleport="options" >Fullscreen</button>
  </div>
</template>
<script>
import { directive as fullscreen } from 'vue-fullscreen'
export default {
  directives: {
    fullscreen
  },
  data() {
    return {
      options: {
        target: ".fullscreen-wrapper",
        callback (isFullscreen) {
          console.log(isFullscreen)
        },
      },
    }
  }
}
</script>

Modifiers

pageOnly

only fill the page with current element.

teleport

the component will be appended to document.body when it is fullscreen.

This can avoid some pop-ups not being displayed.

Options

target

  • Type: String | Element
  • Default: document.body

The element can be specified using a style selector string, equivalent to document.querySelector(target). Note that when passing an element object directly, you need to make sure that the element already exists. The internal elements of the current component may not be initialized when the directive is initialized.

callback

  • Type: Function
  • Default: null

It will be called when the fullscreen mode changed.

fullscreenClass

  • Type: String
  • Default: fullscreen

The class will be added to target element when fullscreen mode is on.

Use as component

You can simply import the component and register it locally.

<template>
  <div>
    <fullscreen v-model="fullscreen" :teleport="teleport" :page-only="pageOnly" >
      Content
    </fullscreen>
    <button type="button" @click="toggle" >Fullscreen</button>
  </div>
</template>
<script>
  import { component } from 'vue-fullscreen'
  export default {
    components: {
      fullscreen: component,
    },
    methods: {
      toggle () {
        this.fullscreen = !this.fullscreen
      },
    },
    data() {
      return {
        fullscreen: false,
        teleport: true,
        pageOnly: false,
      }
    }
  }
</script>

Props

fullscreen-class

  • Type: String
  • Default: fullscreen

The class will be added to the component when fullscreen mode is on.

exit-on-click-wrapper

  • Type: Boolean
  • Default: true

If true, clicking wrapper will exit fullscreen.

page-only

  • Type: Boolean
  • Default: false

If true, only fill the page with current element.

Note: If the browser does not support full-screen Api, this option will be automatically enabled.

teleport

  • Type: Boolean
  • Default: true

If true, the component will be appended to document.body when it is fullscreen.

This can avoid some pop-ups not being displayed.

Events

change

  • isFullscreen: The current fullscreen state.

This event fires when the fullscreen mode changed.

Plugin options

name

  • Type: String
  • Default: fullscreen

If you need to avoid name conflict, you can import it like this:

<template>
  <div>
    <!-- Component  -->
    <fs v-model="fullscreen" :teleport="teleport" :page-only="pageOnly" @change="fullscreenChange" >
      content
    </fs>
    <button type="button" @click="toggle" >Fullscreen</button>
    <!-- Api  -->
    <button type="button" @click="toggleApi" >FullscreenApi</button>
    <!-- Directive  -->
    <button type="button" v-fs.teleport >FullscreenDirective</button>
  </div>
</template>
<script>
import VueFullscreen from 'vue-fullscreen'
import Vue from 'vue'
Vue.use(VueFullscreen, {name: 'fs'})
export default {
  methods: {
    toggle () {
      this.fullscreen = !this.fullscreen
    },
    toggleApi() {
      this.$fs.toggle()
    },
  },
  data() {
    return {
      fullscreen: false,
    }
  }
}
</script>

vue-fullscreen's People

Contributors

balping avatar camc314 avatar dependabot[bot] avatar ferferga avatar mirari avatar qkdreyer avatar tweet avatar vincentdoerig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-fullscreen's Issues

"Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture." toggle() called through global event or wrapper component

  1. : Register a empty vue component for handle global event.
const EventBus = new Vue({
  name: 'EventBus',
});
Vue.set(Vue.prototype, '$bus', EventBus);
  1. : Emit event from you desired component
this.$bus.$emit('fullScreen-toggle');
  1. : Listen the event and cry
mounted() {
      this.$bus.$on('fullScreen-toggle', this.setFullScreen);
    },
    beforeDestroy() {
      this.$bus.$off('fullScreen-toggle');
    },
    methods: {
      setFullScreen() {
        this.$refs['fullscreen'].toggle();
      },
},

Another try with wrapped component ...

  1. Register global component with method
const Test = new Vue({
methodes: {
    async startTest($vm = null) {
        $vm.$root.$children[0].setFullScreen();
    },
},
});

Vue.set(Vue.prototype, '$test', Test);

2 : Add this in #app component...

methods: {
      setFullScreen() {
        this.$refs['fullscreen'].toggle();
      },
  1. call from another component and cry again ....
this.$test.startTest(this);

Failed when publish

Hi, I got build error when run command "tarn run build" or "vue-cli-service build".
FYI, I created Vue project with typescript. Please help to resolve this issue
Screenshot_80

能否支持IE11?

试了一下 live demo,发现在 ie11 下不能使用。
请问有办法修改后在 ie11 下用吗?

Override Escape Key

Hello,
Is it possible to make it where the escape key can be suppressed or ignored with this component?
I have a component which I am trying to use this on that launches other modal dialogs. The escape key is intended to be used to close my modals, however, I can not seem to bypass this functionality by overriding and preventing propagation on my own.

Can you add an option to ignore the esape key to your code ?

Inconsistent licensing

The license on GitHub is MIT, while on NPM is ISC. Is this by design? If not, may I ask you to align the license, maybe to MIT for both, since it's the more popular choice?

vue3注册插件时报错

通过app.use(VueFullscreen)注册时报了这个错误

vue-fullscreen.min.js:1 Uncaught TypeError: Cannot set properties of undefined (setting '$fullscreen')
at Object.install (vue-fullscreen.min.js:1:6671)
at Object.use (runtime-core.esm-bundler.js:3752:18)
at main.ts:16:5

Disabling popout close button

Hey there,

First of all - fantastic package!

Just wondering if there's a way to disable the X in the dark circle that slides in from the top, when the mouse is near the border of the top of the screen?

Thanks in advance.

TypeError: this.$refs.fullscreen.toggle is not a function

Hi! I copy and compile example:

<template>
    <div id="app">
        <fullscreen ref="fullscreen" @change="fullscreenChange">
            Content
        </fullscreen>
        <!--  deprecated
          <fullscreen :fullscreen.sync="fullscreen">
            Content
          </fullscreen>
        -->
        <button type="button" @click="toggle" >Fullscreen</button>
    </div>
</template>
<script>
    import fullscreen from 'vue-fullscreen'
    import Vue from 'vue'
    Vue.use(fullscreen)
    export default {
        methods: {
            toggle () {
                this.$refs['fullscreen'].toggle() // recommended
                // this.fullscreen = !this.fullscreen // deprecated
            },
            fullscreenChange (fullscreen) {
                this.fullscreen = fullscreen
            }
        },
        data() {
            return {
                fullscreen: false
            }
        }
    }
    </script>

In browser:

image

But after click Fullscreen button nothing happened. In browser colsole I see error:

TypeError: this.$refs.fullscreen.toggle is not a function
    at a.toggle (Field:1)
    at It (vendor.js?id=8e2b892a6851ec634c14:1)
    at HTMLButtonElement.n (vendor.js?id=8e2b892a6851ec634c14:1)
    at HTMLButtonElement.Zr.o._wrapper (vendor.js?id=8e2b892a6851ec634c14:1)

Do not work on iOS

  • Vue 3
  • Nuxt
  • iPad / iPhone

Using $fullscreen.toggle(); or v-fullscreen do not work.

全屏元素含iframe时,teleport设置为啥都有bug

当全屏元素中有 iframe 嵌入页面时,设置 teleport 为啥都有问题。teleport 为 false 时 elementUI 的提示框看不到,teleport 为 true 时 iframe 中的 body 被删成空内容没了......


未全屏时:
未全屏时


全屏时:
全屏body消失

全屏之后,上面再有弹框的情况下,会有点击穿透的现象

在没有全屏之前,点击弹框,能操作弹框里面的表单内容。

全屏之后,最开始因为wrapper的层级太高,所以我把弹框的层级设置的比wrapper更高,弹框能出来了,但是却无法操作,鼠标点击的时候,只能点击全屏页面,无法点击全屏页面上面的那个弹框。

请问有其他方法能解决这个问题吗。

Failed to execute 'insertBefore' on 'Node': The new child element contains the parent

image

this is my bug

Failed to execute 'insertBefore' on 'Node': The new child element contains the parent


(in promise) TypeError: fullscreen error
    at Object.eval (vue-fullscreen.min.js?5208:1:1)
    at new Promise (<anonymous>)
    at Object.request (vue-fullscreen.min.js?5208:1:1)
    at Object.request (vue-fullscreen.min.js?5208:1:1)
    at Object.toggle (vue-fullscreen.min.js?5208:1:1)
    at HTMLSpanElement.s [as _onClickFullScreen] (vue-fullscreen.min.js?5208:1:1)

mycode

<div class="sample-tutorial">


    <div class="excel-header">
      <span @click="importExcel(1)" class="btn">导入Excel</span>
      <input v-show="false" ref="fileRef" type="file" @change="fileChange" />
      <span @click="importExcel(2)" class="btn">导入JSON</span>
      <span
        class="btn"
        v-fullscreen.teleport="options"
        @click="$fullscreen.toggle()"
        >全屏</span
      >
    </div>

....

 options: {
        target: ".sample-tutorial",
        // callback(isFullscreen) {
        //   console.log(isFullscreen);
        // },
      },

Blank Full screen

Hey @mirari and @balping the full screen is going blank and only comes up after clicking on the blank screen. This has been experienced for 3rd slide :index=2. What could be the problem? Eagerly expecting your response. Thanks

Compile vue-fullscreen with application

Hi, I have a custom video-player Vue application (using vue-fullscreen) that I am packaging on npm, and using within the client of a different Vue application. Vue-fullscreen works in the first application, but for it to work in the client application, I have to install it there too, and add a rule to the vue-loader.

Is there a way to import vue-fullscreen so that it's included in my video-player application? In other words, I would like to be able to use my video-player in projects that don't have vue-fullscreen explicitly installed.

Sorry if this is documented somewhere, I've been looking but can't find it.

v-for 元素全屏请教

你好, 请问有办法对下面这种通过v-for循环出来的组件进行全屏吗, 我按照教程通过事件加变量的方式全屏没有效果
https://jbaysolutions.github.io/vue-grid-layout/examples/01-basic.html

<grid-layout
        :layout="boardData.layout.data"
        :col-num="12"
        :row-height="30"
        :is-draggable="true"
        :is-resizable="true"
        :is-mirrored="false"
        :vertical-compact="true"
        :margin="[10, 10]"
        :use-css-transforms="true"
>
    <grid-item class="grid-item" v-for="item in boardData.layout.data" :key="item.i"
               :x="item.x" :y="item.y" :w="item.w" :h="item.h" :i="item.i"
               @resized="item.version++">
        <div class="pull-right">
            <button type="button" class="btn btn-default btn-sm" @click="toogle(item)">
                <i class="fa fa-square-o"></i>
            </button>
            <button type="button" class="btn btn-default btn-sm" @click="removeWidget(item)">
                <i class="fa fa-times"></i>
            </button>
        </div>
        <fullscreen :fullscreen.sync="item.fullscreen">
            <widget :widgetId="item.widgetId" :w="item.version"></widget>
        </fullscreen>
    </grid-item>
</grid-layout>
import Fullscreen from "vue-fullscreen/src/component.vue"

methods: {
            toogle(item) {
                item.fullscreen = true;
            },

Crash on Server Side Rendering

import fullscreen from 'vue-fullscreen'
Vue.use(fullscreen)
ReferenceError: document is not defined
    at r (/var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:772)
    at Object.<anonymous> (/var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:3418)
    at t (/var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:330)
    at Object.<anonymous> (/var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:3642)
    at t (/var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:330)
    at /var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:713
    at /var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:722
    at /var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:81
    at Object.<anonymous> (/var/www/html/node_modules/vue-fullscreen/dist/vue-fullscreen.min.js:1:207)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)

Compatibility with Jest

When using the library with Jest Tests in a project I always get a Jest encountered an unexpected token error.
I found several jest specific solutions but couldn't get it working.
e.g. https://forum.vuejs.org/t/vue-testing-with-jest-issues/105763 shows exatly the same problem I am having:

error:

    Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    C:\Users\Ovatones\Desktop\files\dashboard\node_modules\vue-fullscreen\src\utils.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export function supportFullScreen() {
                                                                                             ^^^^^^

    SyntaxError: Unexpected token export

jest.config.js

module.exports = {
  verbose: true,
  moduleFileExtensions: [
      "js",
      "json",
      "jsx",
      "vue"
  ],
  transform: {
      ".*\\.(vue)$": "vue-jest",
      ".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
      "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.jsx?$": "babel-jest",
  },
  moduleNameMapper: {
    "^@/(.*)$": "<rootDir>/src/$1"
  },
  collectCoverage: true,
  collectCoverageFrom: [
      "src/components/*.{js,vue}",
      "!**/node_modules/**"
  ],
  transformIgnorePatterns: ['/node_modules/(?!vue-fullscreen)'],
  coverageReporters: [
      "html",
      "text-summary"
  ],
}

Does someone has experience with vue-fullscreen in combination with Jest? or can point out to me how to vue-fullscreen could be adjusted to be compatible with Jest?

TypeError: $event.stopPropagation is not a function stopPropagation called earlier

We track modal window click if it is outside modal content, close modal

 <em @click.stop="hideModal" />

The button is outside modal, we have to stopPropagination in order to prevent closing modal and open fullscreen

<em @click.stop="toggleFullScreeMode"
v-if="!isFullScreen"
                          />

This way error is thrown

[Vue warn]: Error in v-on handler: "TypeError: $event.stopPropagation is not a function"

found in

---> <Fullscreen>
       <ImageModal> at src/components/public/partials/modal/image_modal.vue
         <PublicGallery> at src/components/public/pages/gallery.vue
           <PublicBasicLayout> at src/components/public/layouts/basic.vue
             <App> at src/App.vue
               <Root>
warn @ vue.js:633
logError @ vue.js:1892
globalHandleError @ vue.js:1887
handleError @ vue.js:1847
invokeWithErrorHandling @ vue.js:1870
invoker @ vue.js:2187
invokeWithErrorHandling @ vue.js:1862
Vue.$emit @ vue.js:3888
fullScreenCallback @ vue-fullscreen.min.js:1
vue.js:1896 TypeError: $event.stopPropagation is not a function
    at change (image_modal.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options:17)
    at invokeWithErrorHandling (vue.js:1862)
    at VueComponent.invoker (vue.js:2187)
    at invokeWithErrorHandling (vue.js:1862)
    at VueComponent.Vue.$emit (vue.js:3888)
    at VueComponent.fullScreenCallback (vue-fullscreen.min.js:1)

Retain fullscreen on redirect

Hi,

I am using vue-fullscreen for a form I created. Once a customer submits the form, he gets redirected to a new page (non vue application outside of the form). When redirecting, the browser automatically exits fullscreen. The only way I can achieve this is by going fullscreen manually by pressing F11 but the "F11 fullscreen" seems to be different from the Javascript fullscreen API.

I am pretty certain this is not a library bug or anything but rather some security feature inside the Javascript Fullscreen API. Anyone an idea on how to retain fullscreen between different pages? I am afraid this is not possible using Javascript Fullscreen API...

Regards,
Jordi

SyntaxError: Unexpected token 'const'

Hey @mirari I keep getting following error when running the package in a linux based system (even on a docker instance)
SyntaxError: Unexpected token 'const' at webpack:///~/vue-fullscreen/src/utils.js:2:0 <- index.js:291193

What could be the problem?

建议把until.js里let变量修改为var 。在项目里使用时,npm run dev正常。npm run build打包报错

export function extend () {
const extended = {}
var deep = false
var i = 0
const length = arguments.length

if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]') {
deep = arguments[0]
i++
}

function merge (obj) {
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
extended[prop] = extend(true, extended[prop], obj[prop])
} else {
extended[prop] = obj[prop]
}
}
}
}

for (var i = 0; i < length; i++) {
var obj = arguments[i]
merge(obj)
}

return extended
}

FullScreen is not working with iPad

Hi,

this.$refs['fullscreen'].toggle() is not working with iPad devices but works with Desktop and Tablets.

How to fix this?

Thanks in advance!

Browser security rejecton: Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.

How to reproduce:

vue init webpack fullscreen-test
cd fullscreen-test
npm install --save vue-fullscreen
npm run dev

Edit ./src/components/HelloWorld.vue

<template>
  <div class="hello">
    <fullscreen :fullscreen.sync="fullscreen">
      Content
    </fullscreen>
    <button type="button" @click="toggle" >Fullscreen</button>
  </div>
</template>

<script>
import fullscreen from 'vue-fullscreen'
import Vue from 'vue'
Vue.use(fullscreen)

export default {
  name: 'HelloWorld',
  methods: {
    toggle () {
      this.fullscreen = !this.fullscreen
    }
  },
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      fullscreen: false
    }
  }
}
</script>

Research:

// Not working through vue-fullscreen recommended method
<button type="button" @click="toggle" >vue-fullscreen</button>

// Works with direct-called plain mozilla fulscreen-request
<button type="button" onclick="body.mozRequestFullScreen()" >onclick fullscreen</button>

// Works with plain mozilla fulscreen-request called from vuejs method
<button type="button" @click="full" >vue-method fullscreen</button>
methods: {
  toggle () {
    this.fullscreen = !this.fullscreen
  },
  full () {
    document.body.mozRequestFullScreen()
  }
}

Tested in Chrome, Fireox

There are several circumstances that will be very stuck.

  1. When the amount of data is large;
  2. Page structure is complex;
  3. When there is a lot of HTML

I view performance in Google Browser,
CPU is especially consumed when rendering is found.
image

image

Number 1 will be enter fullscreen, Number 2 is in fullscreen, Number 3 is exit fullscreen.

What is the solution? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.