extras/noUiSlider/nouislider.js
function checkHandlePosition ( reference, handleNumber, to, lookBackward, lookForward ) {

            // For sliders with multiple handles, limit movement to the other handle.
            // Apply the margin option by adding it to the handle positions.
            if ( scope_Handles.length > 1 ) {

                if ( lookBackward && handleNumber > 0 ) {
                    to = Math.max(to, reference[handleNumber - 1] + options.margin);
                }

                if ( lookForward && handleNumber < scope_Handles.length - 1 ) {
                    to = Math.min(to, reference[handleNumber + 1] - options.margin);
                }
            }

            // The limit option has the opposite effect, limiting handles to a
            // maximum distance from another. Limit must be > 0, as otherwise
            // handles would be unmoveable.
            if ( scope_Handles.length > 1 && options.limit ) {

                if ( lookBackward && handleNumber > 0 ) {
                    to = Math.min(to, reference[handleNumber - 1] + options.limit);
                }

                if ( lookForward && handleNumber < scope_Handles.length - 1 ) {
                    to = Math.max(to, reference[handleNumber + 1] - options.limit);
                }
            }

            // The padding option keeps the handles a certain distance from the
            // edges of the slider. Padding must be > 0.
            if ( options.padding ) {

                if ( handleNumber === 0 ) {
                    to = Math.max(to, options.padding);
                }

                if ( handleNumber === scope_Handles.length - 1 ) {
                    to = Math.min(to, 100 - options.padding);
                }
            }

            to = scope_Spectrum.getStep(to);

            // Limit percentage to the 0 - 100 range
            to = limit(to);

            // Return false if handle can't move
            if ( to === reference[handleNumber] ) {
                return false;
            }

            return to;
        }
function checkHandlePosition ( reference, handleNumber, to, lookBackward, lookForward ) {

            // For sliders with multiple handles, limit movement to the other handle.
            // Apply the margin option by adding it to the handle positions.
            if ( scope_Handles.length > 1 ) {

                if ( lookBackward && handleNumber > 0 ) {
                    to = Math.max(to, reference[handleNumber - 1] + options.margin);
                }

                if ( lookForward && handleNumber < scope_Handles.length - 1 ) {
                    to = Math.min(to, reference[handleNumber + 1] - options.margin);
                }
            }

            // The limit option has the opposite effect, limiting handles to a
            // maximum distance from another. Limit must be > 0, as otherwise
            // handles would be unmoveable.
            if ( scope_Handles.length > 1 && options.limit ) {

                if ( lookBackward && handleNumber > 0 ) {
                    to = Math.min(to, reference[handleNumber - 1] + options.limit);
                }

                if ( lookForward && handleNumber < scope_Handles.length - 1 ) {
                    to = Math.max(to, reference[handleNumber + 1] - options.limit);
                }
            }

            // The padding option keeps the handles a certain distance from the
            // edges of the slider. Padding must be > 0.
            if ( options.padding ) {

                if ( handleNumber === 0 ) {
                    to = Math.max(to, options.padding);
                }

                if ( handleNumber === scope_Handles.length - 1 ) {
                    to = Math.min(to, 100 - options.padding);
                }
            }

            to = scope_Spectrum.getStep(to);

            // Limit percentage to the 0 - 100 range
            to = limit(to);

            // Return false if handle can't move
            if ( to === reference[handleNumber] ) {
                return false;
            }

            return to;
        }
function checkHandlePosition ( reference , handleNumber , to , lookBackward , lookForward ) { // For sliders with multiple handles, limit movement to the other handle. // Apply the margin option by adding it to the handle positions. if ( scope_Handles . length > 1 ) { if ( lookBackward && handleNumber > 0 ) { to = Math . max ( to , reference [ handleNumber - 1 ] + options . margin ) ; } if ( lookForward && handleNumber < scope_Handles . length - 1 ) { to = Math . min ( to , reference [ handleNumber + 1 ] - options . margin ) ; } } // The limit option has the opposite effect, limiting handles to a // maximum distance from another. Limit must be > 0, as otherwise // handles would be unmoveable. if ( scope_Handles . length > 1 && options . limit ) { if ( lookBackward && handleNumber > 0 ) { to = Math . min ( to , reference [ handleNumber - 1 ] + options . limit ) ; } if ( lookForward && handleNumber < scope_Handles . length - 1 ) { to = Math . max ( to , reference [ handleNumber + 1 ] - options . limit ) ; } } // The padding option keeps the handles a certain distance from the // edges of the slider. Padding must be > 0. if ( options . padding ) { if ( handleNumber === 0 ) { to = Math . max ( to , options . padding ) ; } if ( handleNumber === scope_Handles . length - 1 ) { to = Math . min ( to , 100 - options . padding ) ; } } to = scope_Spectrum . getStep ( to ) ; // Limit percentage to the 0 - 100 range to = limit ( to ) ; // Return false if handle can't move if ( to === reference [ handleNumber ] ) { return false ; } return to ; }
Split out the handle positioning logic so the Move event can use it, too
Split out the handle positioning logic so the Move event can use it too