Browse Source

Round jquery width() as jquery 3 returns non-integer value and may break the component

same31 8 năm trước cách đây
mục cha
commit
6dfe7816db

+ 1 - 1
dist/js/bootstrap-switch.js

@@ -424,7 +424,7 @@
         var $handles, handleWidth;
         $handles = this.$on.add(this.$off);
         $handles.add(this.$label).css("width", "");
-        handleWidth = this.options.handleWidth === "auto" ? Math.max(this.$on.width(), this.$off.width()) : this.options.handleWidth;
+        handleWidth = this.options.handleWidth === "auto" ? Math.round(Math.max(this.$on.width(), this.$off.width())) : this.options.handleWidth;
         $handles.width(handleWidth);
         this.$label.width((function(_this) {
           return function(index, width) {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/js/bootstrap-switch.min.js


+ 1 - 1
src/coffee/bootstrap-switch.coffee

@@ -319,7 +319,7 @@ do ($ = window.jQuery, window) ->
 
       # save handleWidth for further label width calculation check
       handleWidth = if @options.handleWidth is "auto"
-      then Math.max @$on.width(), @$off.width()
+      then Math.round Math.max @$on.width(), @$off.width()
       else @options.handleWidth
 
       # set handles width

+ 1 - 1
test/bootstrap-switch.js

@@ -424,7 +424,7 @@
         var $handles, handleWidth;
         $handles = this.$on.add(this.$off);
         $handles.add(this.$label).css("width", "");
-        handleWidth = this.options.handleWidth === "auto" ? Math.max(this.$on.width(), this.$off.width()) : this.options.handleWidth;
+        handleWidth = this.options.handleWidth === "auto" ? Math.round(Math.max(this.$on.width(), this.$off.width())) : this.options.handleWidth;
         $handles.width(handleWidth);
         this.$label.width((function(_this) {
           return function(index, width) {

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác