From 19f1988ef76b79abb841cea5a9f1545910bb9b9a Mon Sep 17 00:00:00 2001 From: Hugh Anderson Date: Thu, 12 Apr 2018 21:52:25 -0400 Subject: [PATCH] Fix unclickable switch center / Rebase PR 630 This change fixes a long-standing issue with the white portion of the Off switch being not clickable. Issues reported on it here: #481 and here: #628 and here, all the same bug, reported since couple of years #467 Plunker to demonstrate bug (uses existing code) https://plnkr.co/edit/wXJvctugqNAx00rgUfeg?p=preview Plunker to demonstrate fix (uses this fork) https://plnkr.co/edit/DY1Icvv4HyDi2D0PkfdU?p=preview When using these Plunkers, set the switch to Off state. Try clicking on the white part of the switch (the part that doesn't say "Off") - notice that it does not switch off in the first Plunker (with bug) and that it correctly switches off in the second Plunker (with my fix) --- src/js/bootstrap-switch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/bootstrap-switch.js b/src/js/bootstrap-switch.js index 291ecc38..4aad2386 100644 --- a/src/js/bootstrap-switch.js +++ b/src/js/bootstrap-switch.js @@ -201,7 +201,7 @@ function prvlabelHandlers() { if (dragStart == null) { return; } const difference = (event.pageX || event.originalEvent.touches[0].pageX) - dragStart; event.preventDefault(); - if (difference < -this.privateHandleWidth || difference > 0) { return; } + if (difference <= -this.privateHandleWidth || difference > 0) { return; } dragEnd = difference; this.$container.css('margin-left', `${dragEnd}px`); },