willowsystems / jSignature

jQuery plugin - draw signature in browser.
720 stars 266 forks source link

how to stop it #27

Open jjhesk opened 11 years ago

jjhesk commented 11 years ago

how do you stop or unbind the touching area.. like when you hit the confirm button it will stop letting the drawings to be continue.

wavesource commented 11 years ago

Set a transparent div over the top with same height/width as canvas using CSS absolute positioning after script div, toggle visibility with javascript, add a radio input to allow user control.

flojug commented 7 years ago

Add this

        , 'stopStroke' : function() {
            var obj = this.find('canvas.'+apinamespace)
                    .add(this.filter('canvas.'+apinamespace))
                    .data(apinamespace+'.this');
            obj.stopStroke = true;
        }
        , 'startStroke' : function() {
            var obj = this.find('canvas.'+apinamespace)
                    .add(this.filter('canvas.'+apinamespace))
                    .data(apinamespace+'.this');
            obj.stopStroke = false;
        }

After

        // there will be a separate one for each jSignature instance.
        , 'events' : function() {
            return this.find('canvas.'+apinamespace)
                    .add(this.filter('canvas.'+apinamespace))
                    .data(apinamespace+'.this').events
        }

And this

            if (jSignatureInstance.stopStroke && (jSignatureInstance.stopStroke==true)) {
                return false;
            }

In the beggining of

        this.drawStartHandler = function(e) {
    // ADD HERE
            e.preventDefault()
            // for performance we cache the offsets
            // we recalc these only at the beginning the stroke
            setStartValues()
            jSignatureInstance.dataEngine.startStroke( getPointFromEvent(e) )
            timer.kick()
        }

And then you start/stop

sig.jSignature("stopStroke");

or

sig.jSignature("startStroke");