Skip to content

Watch progress and fill to fit Vue style. #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuanyui
Copy link

@kuanyui kuanyui commented Feb 13, 2019

Thanks for this JQuery plugin wrapper.

I found the default behavior of this component is a little confusing for developer, that developer must call method in this component via $refs to update the progress, that's quite strange for a Vue plugin. So I add a watch for progress and user should need not to call updateProgress() manually anymore in most scenarios, and this behavior should be more like a Vue plugin which is reactive to the changes of data model.

I didn't build dist in this PR because I encountered the error of "You are using the runtime-only build of Vue..." (so you may need to check the issue #15 first for the dist...)
At last I import VueCircle from 'vue2-circle-progress/src/index.vue' directly and it works great.

@kuanyui kuanyui force-pushed the master branch 2 times, most recently from 928a5a1 to d7289e4 Compare February 13, 2019 03:15
@kuanyui kuanyui changed the title Watch this.progress to fit Vue style. Watch progress and fill to fit Vue style. Feb 13, 2019
@vrajroham
Copy link
Owner

@kuanyui Thanks for your efforts. I'll review and publish this soon.

👏

@@ -88,6 +88,12 @@ export default {
.on('circle-inited', function(event){
renderCircleBody(this, (vm.progress/vm.scale));
vm.$emit('vue-circle-init', event);
vm.$watch('progress', (nv) => {
Copy link
Collaborator

@skinnyjames skinnyjames May 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put these watcher methods into the "watched" property?

 watch: {
    fill(nv) {
      this.updateFill(nv);
    },
    progress(nv) {
      this.updateProgress(nv);
    },
  },

That will help with keep the functions more intentional/declarative.

Copy link
Collaborator

@skinnyjames skinnyjames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you update the demo and the readme?
in App.vue you can do something like:

      redraw(){
        this.p = Math.floor(Math.random() * 100) + 1;
      }

and

     progress(event,progress,stepValue){
        console.log(stepValue);
        if (stepValue > 30) {
          this.fill = '#e3f218';
        }
      },

and we can bump the version and publish when it's compiled

@christopher4lis
Copy link

Idk if this'll help anyone seeing the repo has been inactive for a while, but I made a fork and integrated these changes so fill, emptyFill, and progress are all reactive. Started updating the docs too to reflect all of the possible props you can use:

https://github.com/chriscourses/vue-circle-progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants