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

Allow sharp gradients. #24967

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/components/src/custom-gradient-picker/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export const GRADIENT_MARKERS_WIDTH = 18;
export const MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_MARKER =
( INSERT_POINT_WIDTH + GRADIENT_MARKERS_WIDTH ) / 2;
export const MINIMUM_ABSOLUTE_LEFT_POSITION = 5;
export const MINIMUM_DISTANCE_BETWEEN_POINTS = 9;
export const MINIMUM_DISTANCE_BETWEEN_POINTS = 0;
export const MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT = 10;
export const KEYBOARD_CONTROL_POINT_VARIATION = MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT;
export const MINIMUM_SIGNIFICANT_MOVE = 5;
export const DEFAULT_GRADIENT =
'linear-gradient(135deg, rgba(6, 147, 227, 1) 0%, rgb(155, 81, 224) 100%)';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ControlPoints from './control-points';
import {
INSERT_POINT_WIDTH,
COLOR_POPOVER_PROPS,
MINIMUM_DISTANCE_BETWEEN_POINTS,
MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT,
} from './constants';
import { serializeGradient } from './serializer';
import {
Expand Down Expand Up @@ -175,7 +175,7 @@ export default function CustomGradientBar( { value, onChange } ) {
some( markerPoints, ( { positionValue } ) => {
return (
Math.abs( insertPosition - positionValue ) <
MINIMUM_DISTANCE_BETWEEN_POINTS
MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT
);
} )
) {
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/custom-gradient-picker/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
INSERT_POINT_WIDTH,
MINIMUM_ABSOLUTE_LEFT_POSITION,
MINIMUM_DISTANCE_BETWEEN_POINTS,
KEYBOARD_CONTROL_POINT_VARIATION,
HORIZONTAL_GRADIENT_ORIENTATION,
} from './constants';
import {
Expand Down Expand Up @@ -119,15 +120,15 @@ export function getGradientWithPositionAtIndexIncreased( gradientAST, index ) {
return getGradientWithPositionAtIndexSummed(
gradientAST,
index,
MINIMUM_DISTANCE_BETWEEN_POINTS
KEYBOARD_CONTROL_POINT_VARIATION
);
}

export function getGradientWithPositionAtIndexDecreased( gradientAST, index ) {
return getGradientWithPositionAtIndexSummed(
gradientAST,
index,
-MINIMUM_DISTANCE_BETWEEN_POINTS
-KEYBOARD_CONTROL_POINT_VARIATION
);
}

Expand Down