Git Product home page Git Product logo

Comments (12)

 avatar commented on May 18, 2024

did you find an answer to this?

from jquery-knob.

rollercoasting avatar rollercoasting commented on May 18, 2024

I am also having this issue...

from jquery-knob.

nathd27 avatar nathd27 commented on May 18, 2024

I haven't found an answer and being honnest I haven't search as well... I needed this functionality for a scolar project and this project had to be finish in June so I stopped searching and did with the existing functionality.

from jquery-knob.

saenzramiro avatar saenzramiro commented on May 18, 2024

To make it work you need to add a few lines to the code.

In line # 74 you need to call the "_listen" method. Like this:

var cf = function (e, conf) {
        var k;
        for (k in conf) {
            s.o[k] = conf[k];
        }
        s.init();
        s._configure()
                 ._listen()
                 ._draw();
};

Then, in the "_listen" method at line arround # 320 just add these few lines in the "else":

} else {
        this.$c.unbind("mousedown");
        this.$c.unbind("touchstart");
        this.$.attr('readonly', 'readonly');
}

Then you need to call the change:

$('.knob').trigger('configure',{'readOnly': true});

from jquery-knob.

kgodard avatar kgodard commented on May 18, 2024

Thanks @saenzramiro ! Is there a pull request for this fix ?

from jquery-knob.

sheillendra avatar sheillendra commented on May 18, 2024

not yet, for up and down arrows are still not readonly

add this line in the "else" in the "_listen" method:

this.i.unbind("keydown");

from jquery-knob.

ellisgl avatar ellisgl commented on May 18, 2024

Codes has changed a bit, this hack doesn't work anymore. =(

from jquery-knob.

SarvagyaVaish avatar SarvagyaVaish commented on May 18, 2024

The hack still works.. the only difference is that the line numbers have changed.
From Line #74 to #80.
From Line #320 to #419.

from jquery-knob.

Ephigenia avatar Ephigenia commented on May 18, 2024

👍 for a pull request on this

from jquery-knob.

adamclifford avatar adamclifford commented on May 18, 2024

For others who are also looking at this issue,

if you update the _listen function to look like this, the scroll wheel and arrow keys will function as intended.

this._listen = function () {
            if (!this.o.readOnly) {
            this.$.removeAttr('readonly');
            this.$c.unbind('mousedown');
            this.$c.unbind('touchstart');
            this.$.unbind('keydown');
            this.$c.unbind("mousewheel DOMMouseScroll");
            this.$.unbind("mousewheel DOMMouseScroll");
                this.$.unbind('keyup');
                this.$c
                    .bind(
                        "mousedown",
                        function (e) {
                            e.preventDefault();
                            s._xy()._mouse(e);
                        }
                    )
                    .bind(
                        "touchstart",
                        function (e) {
                            e.preventDefault();
                            s._xy()._touch(e);
                        }
                    );

                this.listen();
            } else {
            this.$c.unbind('mousedown');
            this.$c.unbind('touchstart');
            this.$.unbind('keydown');
            this.$c.unbind("mousewheel DOMMouseScroll");
            this.$.unbind("mousewheel DOMMouseScroll");
                this.$.attr('readonly', 'readonly');
            }

            if (this.relative) {
                $(window).resize(function () {
                    s._carve().init();
                    s._draw();
                });
            }

            return this;
        };

from jquery-knob.

EddieOne avatar EddieOne commented on May 18, 2024

So how do we update readonly?

from jquery-knob.

 avatar commented on May 18, 2024

with the last code provided it doesn't work :(

somebody can help ? Thanks

from jquery-knob.

Related Issues (20)

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.