Giter Site home page Giter Site logo

oguzsert / vue-component-loading-screen Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 756 KB

A simple plugin for show an indicator when your component is busy

License: MIT License

JavaScript 42.62% HTML 9.65% Vue 43.57% CSS 4.16%
vue loading screen component

vue-component-loading-screen's Introduction

VUE-COMPONENT-LOADING-SCREEN PLUGIN

Vue Component Loading screen is a simple plugin for show an indicator when your component is busy.

  • You can activate/disable loading screens manually
  • You can bind your screen states to [Axios].

Installation

$ npm install vue-component-loading-screen

Demonstration page

$ npm run serve

Implementation

import Vue from 'vue'
import App from './App.vue'
import VueComponentLoadingScreenPlugin from "vue-component-loading-screen";
import "vue-component-loading-screen/vue-component-loading-screen.css";

Vue.use(VueComponentLoadingScreenPlugin,{
  loadingImage:"[YOUR LOADING IMAGE PATH]", //-> Required
  overlayBackgroundColor:"rgba(0,0,0,0.3)" //-> Optional (RGB OR HEX)
});

Manual Screen Activation

export default {
  name: 'HelloWorld',
  methods:{
      exampleMethod(){
          this.COMPONENT_IS_BUSY(); //->Activates loading screen
          /*
          Bunch of code doing something.
          ..................
          ..............................
          .........................................
          */
          this.COMPONENT_IS_IDLE(); // -> Disables loading screen
      }
  }
}

Binding Screen States To Axios Instance

Loading screen activates before request sent and disables when response received or error occured.

import axios from "axios";
export default {
  name: 'HelloWorld',
  methods:{
    sendAjax(){
        var yourAxiosInstance = axios.create({
              baseURL: '[SOME API PATH]'
        });
        this.bindLoadingScreenToAxios(yourAxiosInstance);
        yourAxiosInstance();
    }
  }
}

OPTIONS

Option Description Is Required Default Value
loadingImage Path of your loading image true -
overlayBackgroundColor Loading screen background color. You can set HEX or RGB value false rgba(0,0,0,0.5)
License

MIT

vue-component-loading-screen's People

Stargazers

 avatar Eray Köse avatar

Watchers

Oğuz Sert 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.