nz-toggle icon indicating copy to clipboard operation
nz-toggle copied to clipboard

Unexpected state after click

Open hartmannj opened this issue 9 years ago • 2 comments

The interaction seems to go against the mental model of a switch. If I click on the right side of a switch, it should switch to the right side and the other way round. Right now it has a predefined order no matter which side I click. Is this the expected behaviour?

hartmannj avatar Nov 22 '15 11:11 hartmannj

Hi,

Yes this is the expected behaviour. You also have the option of dragging it to the direction you want.

ckr avatar May 23 '16 23:05 ckr

I had the same problem. I solved it by changing onClick to:

            function onClick(e) {

                if (movement < 1) {

                    if (vm.state === 'null') {

                        const element = angular.element(this);
                        const width = element.innerWidth(); //use .outerWidth() if you want borders
                        const offset = element.offset(); 
                        const x = e.pageX - offset.left;
                        const middle = width / 2;

                        if (x < middle) {

                            toggle('false');

                        } else {

                            toggle('true');

                        } 

                    } else {

                        toggle();

                    }

                }

            }

StylishFlash avatar Aug 19 '16 15:08 StylishFlash