GithubHelp home page GithubHelp logo

biigpongsatorn / vue-element-loading Goto Github PK

View Code? Open in Web Editor NEW
321.0 7.0 31.0 1.21 MB

⏳ Loading inside a container or full screen for Vue.js

Home Page: https://vue-element-loading.netlify.com/

License: MIT License

JavaScript 11.86% Vue 87.17% HTML 0.96%
loader loading spinner inside component vue vuejs2

vue-element-loading's Introduction

⛔️ DEPRECATED This repo has not been maintained

NPM version NPM downloads License Build Status

vue-element-loading

⏳ Loading inside a container or full screen for Vue.js

👀 Document & Demo Page

💻 Install

npm install --save vue-element-loading

or

yarn add vue-element-loading

🖥 Install (Vue 3)

npm install --save vue-element-loading@next

or

yarn add vue-element-loading@next

🕹 Usage

import Vue from "vue";
import VueElementLoading from "vue-element-loading";

Vue.component("VueElementLoading", VueElementLoading);

or

import VueElementLoading from "vue-element-loading";

export default {
  components: {
    VueElementLoading
  }
};

🔎 Example

Inside container

<div class="parent">
  <vue-element-loading :active="show" spinner="bar-fade-scale" />
  <span>
    This is my content.
  </span>
</div>

Full screen

<body>
  <vue-element-loading :active="show" is-full-screen />
</body>

Adjust Spinner Color

Use the color parameter to set the color of the displayed spinner (does not affect custom spinner images).

<div class="parent">
  <vue-element-loading
    :active="show"
    spinner="bar-fade-scale"
    color="#FF6700"
  />
  <span>
    This is my content.
  </span>
</div>

Set text

Use the text parameter to set the text which will appear below loader.

<div class="parent">
  <vue-element-loading
    :active="show"
    spinner="bar-fade-scale"
    color="#FF6700"
    text="Please wait..."
  />
  <span>
    This is my content.
  </span>
</div>

Set text style

Use the textStyle parameter to set the style of text( you need to pass css-in-js way using camelCase exp. fontSize, backgroundColor etc).

<div class="parent">
  <vue-element-loading
    :active="show"
    spinner="bar-fade-scale"
    color="#FF6700"
    text="Please textStyle={fontSize: '25px'}  wait..."
  />
  <span>
    This is my content.
  </span>
</div>

Adjust Spinner Size

Use the size parameter to set the size of the displayed spinner (does not affect custom spinner images).

<div class="parent">
  <vue-element-loading :active="show" spinner="bar-fade-scale" size="128" />
  <span>
    This is my content.
  </span>
</div>

Adjust Spinner Animation Speed

Use the duration parameter to set the animation loop duration in seconds (does not affect custom spinner images).

<div class="parent">
  <vue-element-loading :active="show" spinner="bar-fade-scale" duration="1.0" />
  <span>
    This is my content.
  </span>
</div>

Customize loader

<div class="parent">
  <vue-element-loading :active="show">
    <img src="/static/pikachu.gif" width="55px" height="55px" />
  </vue-element-loading>
</div>

🌀 Spinner

See full document here.

⚙️ Props

Props Type Default Description
active Boolean - Status for show/hide loading
spinner String spinner Spinner icon name: spinner, mini-spinner, ring, line-wave, line-scale, line-down, bar-fade, bar-fade-scale
color String #000 Color of spinner icon
background-color String rgba(255, 255, 255, .9) Background color of spinner icon (for overlay)
size String "40" The size to display the spinner in pixels (NOTE: this will not affect custom spinner images)
duration String "0.6" The duration of one 'loop' of the spinner animation, in seconds (NOTE: this will not affect custom spinner images)
delay Number | String 0 The minimum appearing duration of loading in seconds
is-full-screen Boolean false Loader will overlay the full page
text String - Text will appear below loader
text-style Object {} Change style of the text below loader

🤝 Contributing

  1. Fork this repository.
  2. Create new branch with feature name.
  3. Run npm install and npm run dev.
  4. Create your feature.
  5. Commit and set commit message with feature name.
  6. Push your code to your fork repository.
  7. Create pull request. 🙂

⭐️ Support

If you like this project, You can support me with starring ⭐ this repository.

📄 License

MIT

Developed with ❤️ and ☕️

vue-element-loading's People

Contributors

adlaws avatar ansidev avatar biigpongsatorn avatar dependabot[bot] avatar enigma10 avatar n-osennij avatar runyasak avatar sktzofrenic 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-element-loading's Issues

compatibility with Vue 3?

I was testing this with Vue 3 and adding

import VueElementLoading from 'vue-element-loading'

and

<vue-element-loading :active="isActive" spinner="bar-fade-scale" color="#FF6700"/>

in my component is giving all sorts of errors.

Property "isActive" was accessed during render but is not defined on instance. 
TypeError: selfHook.call is not a function
Uncaught (in promise) TypeError: Cannot read property 'parentNode' of null

and so on..

Any fixes as Vue 3 is coming out soon..

How do you stop the spinner?

The spinner keeps loading even after the component has loaded all the data.
How do you stop it or give it a timer like a certain number of seconds?

Set default config

Is there a way when using as a component to set default config so you dont have to put it in every place the loader is used?

import Vue from 'vue'
import VueElementLoading from 'vue-element-loading'

const options = {
     spinner:"spinner",
     color:"#E91E63"
}

Vue.component('VueElementLoading', VueElementLoading)

change Background Color

Hello,
excellent app 👍 , I have a question, is it possible to change the color of the background, by means of a property in vue-element-loading, as well as a color is passed in the color property?

Example:

<vue-element-loading :active="isActive" spinner="bar-fade-scale" color="#FF6700" background="#1a1b1c"/>

in the file: src/index.vue

.velmld-overlay {
  background-color: rgba(255, 255, 255, .9);
}

Thanks!

How to start / stop loading element programmatically?

On the doc, i have to use something like this

<vue-element-loading :active="show" spinner="bar-fade-scale" color="#FF6700"/>

but how can i start/stop loading element like this for full screen

this.$loading.start() 
this.$loading.stop()

$loading could be something else to prevent conflict with other library

Thanks

Minified version was not updated !

It was fixed recently but it seems not in minified version ! I got this error when using it with v1.1.

[Vue warn]: Invalid default value for prop "textStyle": Props with type Object/Array must use a factory function to return the default value.

found in

---> <VueElementLoading> at index.vue
       <AppButtonPrincipal> at src\components\ui\AppButtonPrincipal.vue
         <Index> at src\components\pages\OverviewPage\index.vue
           <TheDashboard> at src\components\layout\TheDashboard.vue
             <App> at src\App.vue
               <Root>

SSR ReferenceError: document is not defined

Hi everyone I faced problem in vue ssr project
When I import vue-element-loading I get this error in ssr:

ReferenceError: document is not defined
    at /Users/denis/Documents/projects/project-ssr/node_modules/vue-element-loading/node_modules/vue-runtime-helpers/inject-style/browser.js:6:14
    at /Users/denis/Documents/projects/project-ssr/node_modules/vue-element-loading/lib/vue-element-loading.min.js:6:84
    at Object.<anonymous> (/Users/denis/Documents/projects/project-ssr/node_modules/vue-element-loading/lib/vue-element-loading.min.js:6:160)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Module._compile (/Users/denis/Documents/projects/project-ssr/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Object.newLoader [as .js] (/Users/denis/Documents/projects/project-ssr/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at r (/Users/denis/Documents/projects/project-ssr/node_modules/vue-server-renderer/build.dev.js:9315:16)
    at eval (webpack-internal:///vue-element-loading:1:18)
    at Object.vue-element-loading (main.js:1566:1)
    at __webpack_require__ (main.js:21:30)
    at eval (webpack-internal:///../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js?!./vue/blog/index.vue?vue&type=script&lang=js&:14:49)

And in client:
500 | Internal Server Error

Fixed it all, please merge and publish to npm
Made the module even better I hope it will not be difficult for you to allocate a few minutes for this
Thanks

Old Versions

Why did you pull down all the older versions?
Anything after 1.0.6 breaks in Nuxt since you added in the div for text to display when loading it will not work in Nuxt.

Now I need 1.0.6 and all you have available is 1.1.4 which is useless to me.

Please put back the other versions.

[Feature request] Loader delay

Sometime the same loading action can take from 0.01 second to 2 seconds. If the loading takes less than ~0.5 second user will only see a "blink". Is it possible to add delay which prevents from showing the loader if the "active" value will be set to true for less than X milliseconds?

Functions

Hi, I am using axios interceptors to catch unsuccessful requests. and wonder if there is any function or events that I could call to hide the loading from axios like for example "hide_all_loadings()"?

Currently I am firing a global event from axios interceptor indicating request finishing and listening for it inside each individual component to hide the loading.

It's working very well in global loading. but it would be convenient to add such a feature. It will make code simpler and centralized.

export default {
	data() {
		return {
			loading: false
		}
	},
	created(){
		EventBus.$on('RequestFinished', r =>{ this.loading = false; });
	},
	update() {
		this.loading = true;
		axios.post('/api/citizen/info',{form:this.form}).then(({data}) => {
			this.loading = false;
		});
	}
}
window.axios.interceptors.response.use(axiosSuccessInterceptor, axiosErrorInterceptor);

function axiosSuccessInterceptor(response) {
      EventBus.$emit('RequestFinished', response);
}

function axiosErrorInterceptor(response) {
      EventBus.$emit('RequestFinished', response);
}

npm version 2.0.1 is latest now not working on vue 2

Uncaught TypeError: Object(...) is not a function
    at Module.fb15 (VueElementLoading.common.js:661)
    at __webpack_require__ (VueElementLoading.common.js:21)
    at eval (VueElementLoading.common.js:85)
    at eval (VueElementLoading.common.js:88)
    at Object.../node_modules/vue-element-loading/dist/VueElementLoading.common.js (vendors~index.chunk.js:3731)
    at __webpack_require__ (index.bundle.js:80)
    at eval (day.vue?../node_modules/babel-loader/lib!../node_modules/vue-loader/lib??vue-loader-options:18)
    at Object.../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js?!./src/vue/components/dashboard/user/widgets/day.vue?vue&type=script&lang=js& (index.bundle.js:514)
    at __webpack_require__ (index.bundle.js:80)
    at eval (VM1323 day.vue:2)
    at Module../src/vue/components/dashboard/user/widgets/day.vue?vue&type=script&lang=js& (index.bundle.js:4275)
    at __webpack_require__ (index.bundle.js:80)
    at eval (VM1323 day.vue:3)
    at Module../src/vue/components/dashboard/user/widgets/day.vue (index.bundle.js:4263)
    at __webpack_require__ (index.bundle.js:80)
    at Object.eval (dashboard.vue?../node_modules/babel-loader/lib!../node_modules/vue-loader/lib??vue-loader-options:24)

When users update the module in vue 2 projects, they will receive this error since the current version of the module is in the master branch for vue 3. I already said this, but I will repeat the current version of the module in npm, you need to publish with the tag next (npm publish --tag next)
Now you need to remove the 2.0.1 module version from npm so that the 1.1.6 module remains working for vue 2.

In the readme, add information to install the module in the vue 3 project, you need to run the command:

npm i vue-element-loading@next

[Vue warn]: Property or method "isActive" is not defined on the instance but referenced during render.

I'm facing this error

[Vue warn]: Property or method "isActive" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

my code

<template>
	<div>
		<vue-element-loading :active="isActive" :is-full-screen="true"/>
	</div>
</template>


<script>
import VueElementLoading from 'vue-element-loading';
    export default {
    	data() {
            return {
                app_name: process.env.MIX_APP_NAME,
            }
        },
        components: {
            VueElementLoading
        }
    }
</script>

+ How can I select the type of loader i want?

any idea?

Integrate with axios

Using it this way:

  async created () {
    this.isActive = true
    await this.fetchData()
    this.isActive = false
  }

fetchData() is axios.get request, so i want to display loader till axios request is complete. How can i accomplish?

Size is not taking effect

Size is always 40px whatever value you pass its always the same

<button @click="apply(props.row)" class="btn green-haze">
      <span v-if="!applying"><i class="fas fa-check"></i> Apply</span>
      <vue-element-loading :active="applying" size="25" spinner="ring" color="#ffffff"/>
</button>

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.