switchery icon indicating copy to clipboard operation
switchery copied to clipboard

Switchery to be even usable needs drag support. come on now

Open faceyspacey opened this issue 11 years ago • 11 comments

it makes zero sense that u would make a replica of the iOS7 switch without the drag feature. come on now. It's totally possible. transforms (i.e. translateX) should have been used rather than transitions.

Tell me your recommended way to implement this, and I'll do it and submit a pull request.

faceyspacey avatar Jun 15 '14 02:06 faceyspacey

+1

corcorans avatar Sep 02 '14 16:09 corcorans

Yes, this would be nice.

ottob avatar Dec 01 '14 11:12 ottob

+1 - our users are getting tripped up, thinking they can drag the switch over, not realizing it can only be tapped. An upgrade here would be amazing!

brianglick avatar Dec 08 '14 18:12 brianglick

+1

prud avatar Jan 06 '15 14:01 prud

+1

Xiphe avatar Apr 07 '15 14:04 Xiphe

+1

Sanafan avatar May 19 '15 15:05 Sanafan

Nothing changed here... someone able to add this feature on his own?

Sanafan avatar Sep 21 '15 08:09 Sanafan

asabirov avatar Dec 02 '15 14:12 asabirov

With jQuery, I've added this feature as follows:

            //Switchery initialization
            var init = new Switchery(document.querySelector('.js-switch'));
            setTimeout(function () {
                var _self = $(".switchery"),
                    startPos = { x: 0, y: 0 },
                    currentPos = { x: 0, y: 0 };
                var el=_self.find("small").get(0);
                el.addEventListener('touchstart', function (event) {
                    startPos = { x: event.changedTouches[0].pageX, y: event.changedTouches[0].pageY };
                }, false);
                el.addEventListener('touchmove', function (event) {
                    event.preventDefault();
                    currentPos = { x: event.changedTouches[0].pageX, y: event.changedTouches[0].pageY };
                }, false);
                el.addEventListener('touchend', function (event) {
                    currentPos = { x: event.changedTouches[0].pageX, y: event.changedTouches[0].pageY };
                    if (currentPos.x != startPos.x){
                        _self.trigger("click");//here is the key hack!
                    }
                    startPos = { x: 0, y: 0 },
                    currentPos = { x: 0, y: 0 };
                }, false);
            }, 1000);

nelsonkuang avatar Jan 26 '16 08:01 nelsonkuang

@nelsonkuang Thanks, but what if I have multiple switches on a page?

grundmanise avatar Sep 05 '16 13:09 grundmanise

@nelsonkuang Snippet looks good, could you make a PR?

CodeBrauer avatar Apr 03 '17 09:04 CodeBrauer