Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion with non-crossable grips #20

Open
thinkMichel opened this issue Mar 29, 2015 · 0 comments
Open

Suggestion with non-crossable grips #20

thinkMichel opened this issue Mar 29, 2015 · 0 comments

Comments

@thinkMichel
Copy link

Given the custom style:
image image

I wanted the handles not to cross, but also not overlap. I understand that this would currently result in the fact that the range values will not be the same on left and right. Which is fine for my use-case.

I modified the function "validateAndMoveGripsToPx", and included a conditional statement tin the if statement (last part:)

  'validateAndMoveGripsToPx': function (nextLeftGripPositionPx, nextRightGripPositionPx) {
            var $this = this;

            //[! edit:
            settings = $this.data('settings'); // added settings to get crossable_handles value
            // end edit !]
            var draggableAreaLengthPx = _methods.getSliderWidthPx.call($this) - $this.data('left_grip_width');

            //
            // Validate & Move
            //
            if (nextRightGripPositionPx <= draggableAreaLengthPx &&
                nextLeftGripPositionPx >= 0 &&
                nextLeftGripPositionPx <= draggableAreaLengthPx &&
                (!$this.data('has_right_grip') || nextLeftGripPositionPx <=
                nextRightGripPositionPx
                // [! edit:
                // subtract the grip width to let the handles stop when they touch..
                - (!settings.crossable_handles ? $this.data('left_grip_width') : 0)
                // end edit!]
                )) {

                var prevMin = $this.data('cur_min'),
                    prevMax = $this.data('cur_max');

                // note: also stores new cur_min, cur_max
                _methods.set_position_from_px.call($this, nextLeftGripPositionPx, nextRightGripPositionPx);

                // set the style of the grips according to the highlighted range
                _methods.refresh_grips_style.call($this);

                _methods.notify_changed_implicit.call($this, 'drag_move', prevMin, prevMax);
            }

            return $this;
        },

Of course it would be beter if this was an additional setting, because now when not allowing to cross, it will always force the 'no touch' policy (actually a better name would be 'touch slightly only' 😄 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant