GithubHelp home page GithubHelp logo

jagfx / vue-insomnia Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gorbypark/vue-insomnia

0.0 0.0 0.0 15 KB

Prevents the display of a mobile device from going to sleep by playing a small mp4 video that's positioned off screen on a loop (aka wake lock).

License: MIT License

JavaScript 100.00%

vue-insomnia's Introduction

vue-insomnia

Prevents the display of a mobile device from going to sleep by playing a small (6kb) mp4 video that's positioned off screen on a loop.

Installation

Import into your project using npm or yarn.

yarn add vue-insomnia or npm install --save vue-insomnia

Vue 3.x

Usage

<template>
    <button @click="enableVueInsomnia">Wake Lock on</button>
    <button @click="disableVueInsomnia">Wake Lock off</button>
</template>

<script setup>
  const { enableVueInsomnia, disableVueInsomnia } = useVueInsomnia();
</script>

Vue 2.x

In your main.js (or equivalent) import and then use vue-insomnia.

import vueInsomnia from "vue-insomnia";

Vue.use(vueInsomnia);

Usage

There are two methods globally available, vueInsomnia().on() and vueInsomnia().off(), to toggle screen wake lock on and off, respectively. For example, to turn on the wake lock when a component is loaded:

mounted: {
  this.vueInsomnia().on();
}

or to use in a component template:

Add a method

methods: {
  wakeLockOn() {
    this.vueInsomnia().on();
  },
  wakeLockOff() {
    this.vueInsomnia().off();
  }
}

and then use the method:

<button @click="wakeLockOn">Wake Lock on</button>

vue-insomnia's People

Contributors

gorbypark avatar jagfx avatar

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.